[PATCH 4/5] d3dcompiler: Stub parser.

Matteo Bruni mbruni at codeweavers.com
Mon May 14 10:24:04 CDT 2012


---
 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 +++++++++++++++++++++++++++++
 4 files changed, 126 insertions(+), 8 deletions(-)
 create mode 100644 dlls/d3dcompiler_43/hlsl.y

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 a50ad21..b3ce120 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;
+}
-- 
1.7.3.4




More information about the wine-patches mailing list