Module: wine Branch: master Commit: 949de2e520d25dd8c4fca5cad78346faed981199 URL: http://source.winehq.org/git/wine.git/?a=commit;h=949de2e520d25dd8c4fca5cad7...
Author: Matteo Bruni mbruni@codeweavers.com Date: Tue May 15 16:12:56 2012 +0200
d3dcompiler: Add a stub parser.
---
.gitignore | 2 + dlls/d3dcompiler_43/Makefile.in | 4 +- dlls/d3dcompiler_43/compiler.c | 7 -- dlls/d3dcompiler_43/d3dcompiler_private.h | 29 +++++++++ dlls/d3dcompiler_43/hlsl.y | 94 +++++++++++++++++++++++++++++ 5 files changed, 128 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore index 3b22ee6..7f4bb73 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,8 @@ dlls/advapi32/svcctl_c.c dlls/d3dcompiler_43/asmshader.tab.c dlls/d3dcompiler_43/asmshader.tab.h dlls/d3dcompiler_43/asmshader.yy.c +dlls/d3dcompiler_43/hlsl.tab.c +dlls/d3dcompiler_43/hlsl.tab.h dlls/dispex/disp_ex.h dlls/dispex/disp_ex_p.c dlls/dxdiagn/fil_data.h diff --git a/dlls/d3dcompiler_43/Makefile.in b/dlls/d3dcompiler_43/Makefile.in index f69eb77..15a9dc4 100644 --- a/dlls/d3dcompiler_43/Makefile.in +++ b/dlls/d3dcompiler_43/Makefile.in @@ -13,7 +13,9 @@ C_SRCS = \ utils.c
LEX_SRCS = asmshader.l -BISON_SRCS = asmshader.y +BISON_SRCS = \ + asmshader.y \ + hlsl.y
RC_SRCS = version.rc
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 8ed7be1..043d231 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -490,13 +490,6 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena return hr; }
-static struct bwriter_shader *parse_hlsl_shader(const char *text, enum shader_type type, DWORD version, - const char *entrypoint, char **messages) -{ - FIXME("\n"); - return NULL; -} - static HRESULT compile_shader(const char *preproc_shader, const char *target, const char *entrypoint, ID3DBlob **shader_blob, ID3DBlob **error_messages) { diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index e64f4cf..2936077 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -573,6 +573,35 @@ struct bwriter_shader *SlAssembleShader(const char *text, char **messages) DECLS HRESULT SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result, DWORD *size) DECLSPEC_HIDDEN; void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN;
+enum hlsl_matrix_majority +{ + HLSL_COLUMN_MAJOR, + HLSL_ROW_MAJOR +}; + +struct hlsl_parse_ctx +{ + char *source_file; + unsigned int line_no; + enum parse_status status; + struct compilation_messages messages; + + struct hlsl_scope *cur_scope; + struct hlsl_scope *globals; + struct list scopes; + + struct list types; + struct list functions; + + enum hlsl_matrix_majority matrix_majority; +}; + +extern struct hlsl_parse_ctx hlsl_ctx DECLSPEC_HIDDEN; + +void hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN; +struct bwriter_shader *parse_hlsl_shader(const char *text, enum shader_type type, DWORD version, + const char *entrypoint, char **messages) DECLSPEC_HIDDEN; + #define MAKE_TAG(ch0, ch1, ch2, ch3) \ ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \ ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 )) diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y new file mode 100644 index 0000000..2010f5f --- /dev/null +++ b/dlls/d3dcompiler_43/hlsl.y @@ -0,0 +1,94 @@ +/* + * HLSL parser + * + * Copyright 2008 Stefan Dösinger + * Copyright 2012 Matteo Bruni for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ +%{ +#include "config.h" +#include "wine/debug.h" + +#include <stdio.h> + +#include "d3dcompiler_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(hlsl_parser); + +int hlsl_lex(void) +{ + FIXME("Lexer.\n"); + return 0; +} + +struct hlsl_parse_ctx hlsl_ctx; + +void hlsl_message(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + compilation_message(&hlsl_ctx.messages, fmt, args); + va_end(args); +} + +static void hlsl_error(const char *s) +{ + hlsl_message("Line %u: %s\n", hlsl_ctx.line_no, s); + set_parse_status(&hlsl_ctx.status, PARSE_ERR); +} + +%} + +%error-verbose + +%union +{ + char *name; + INT intval; +} + +%token <intval> PRE_LINE + +%token <name> STRING +%% + +hlsl_prog: /* empty */ + { + } + | hlsl_prog preproc_directive + { + } + +preproc_directive: PRE_LINE STRING + { + TRACE("Updating line informations to file %s, line %u\n", debugstr_a($2), $1); + hlsl_ctx.line_no = $1 - 1; + d3dcompiler_free(hlsl_ctx.source_file); + hlsl_ctx.source_file = $2; + } + +%% + +struct bwriter_shader *parse_hlsl_shader(const char *text, enum shader_type type, DWORD version, const char *entrypoint, char **messages) +{ + hlsl_ctx.line_no = 1; + hlsl_ctx.matrix_majority = HLSL_COLUMN_MAJOR; + + hlsl_parse(); + + return NULL; +}