Matteo Bruni : d3dcompiler: Pass the shader filename to the preprocessor.

Alexandre Julliard julliard at winehq.org
Wed Jul 11 17:39:21 CDT 2012


Module: wine
Branch: master
Commit: 3d052768ab04187434ca53aec9a9095fd5671b27
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3d052768ab04187434ca53aec9a9095fd5671b27

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Wed Jul 11 17:27:51 2012 +0200

d3dcompiler: Pass the shader filename to the preprocessor.

---

 dlls/d3dcompiler_43/compiler.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c
index f08e713..9f1ed86 100644
--- a/dlls/d3dcompiler_43/compiler.c
+++ b/dlls/d3dcompiler_43/compiler.c
@@ -41,6 +41,7 @@ struct mem_file_desc
 
 static struct mem_file_desc current_shader;
 static ID3DInclude *current_include;
+static const char *initial_filename;
 
 #define INCLUDES_INITIAL_CAPACITY 4
 
@@ -179,7 +180,7 @@ static void *wpp_open_mem(const char *filename, int type)
     struct mem_file_desc *desc;
     HRESULT hr;
 
-    if(filename[0] == '\0') /* "" means to load the initial shader */
+    if(!strcmp(filename, initial_filename))
     {
         current_shader.pos = 0;
         return &current_shader;
@@ -310,7 +311,7 @@ static int wpp_close_output(void)
     return 1;
 }
 
-static HRESULT preprocess_shader(const void *data, SIZE_T data_size,
+static HRESULT preprocess_shader(const void *data, SIZE_T data_size, const char *filename,
         const D3D_SHADER_MACRO *defines, ID3DInclude *include, ID3DBlob **error_messages)
 {
     int ret;
@@ -347,8 +348,9 @@ static HRESULT preprocess_shader(const void *data, SIZE_T data_size,
     wpp_messages = NULL;
     current_shader.buffer = data;
     current_shader.size = data_size;
+    initial_filename = filename ? filename : "";
 
-    ret = wpp_parse("", NULL);
+    ret = wpp_parse(initial_filename, NULL);
     if (!wpp_close_output())
         ret = 1;
     if (ret)
@@ -481,7 +483,7 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena
     if (shader) *shader = NULL;
     if (error_messages) *error_messages = NULL;
 
-    hr = preprocess_shader(data, datasize, defines, include, error_messages);
+    hr = preprocess_shader(data, datasize, filename, defines, include, error_messages);
     if (SUCCEEDED(hr))
         hr = assemble_shader(wpp_output, shader, error_messages);
 
@@ -615,7 +617,7 @@ HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filena
 
     EnterCriticalSection(&wpp_mutex);
 
-    hr = preprocess_shader(data, data_size, defines, include, error_messages);
+    hr = preprocess_shader(data, data_size, filename, defines, include, error_messages);
     if (SUCCEEDED(hr))
         hr = compile_shader(wpp_output, target, entrypoint, shader, error_messages);
 
@@ -639,7 +641,7 @@ HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename
     if (shader) *shader = NULL;
     if (error_messages) *error_messages = NULL;
 
-    hr = preprocess_shader(data, size, defines, include, error_messages);
+    hr = preprocess_shader(data, size, filename, defines, include, error_messages);
 
     if (SUCCEEDED(hr))
     {




More information about the wine-cvs mailing list