[D3DCOMPILER_43] Sync with Wine Staging 3.17. CORE-15127
[reactos.git] / dll / directx / wine / d3dcompiler_43 / compiler.c
index c5f3bfe..53d2a43 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include "d3dcompiler_private.h"
+#define COBJMACROS
+#include "config.h"
+#include "wine/port.h"
+#include "wine/debug.h"
 #include "wine/unicode.h"
+
+#include "d3dcompiler_private.h"
 #include "wine/wpp.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
@@ -140,12 +145,15 @@ static void wpp_warning(const char *file, int line, int col, const char *_near,
 static char *wpp_lookup_mem(const char *filename, int type, const char *parent_name,
                             char **include_path, int include_path_count)
 {
-    /* Here we return always ok. We will maybe fail on the next wpp_open_mem */
+    /* We don't check for file existence here. We will potentially fail on
+     * the following wpp_open_mem(). */
     char *path;
     int i;
 
+    TRACE("Looking for include %s, parent %s.\n", debugstr_a(filename), debugstr_a(parent_name));
+
     parent_include = NULL;
-    if(parent_name[0] != '\0')
+    if (strcmp(parent_name, initial_filename))
     {
         for(i = 0; i < includes_size; i++)
         {
@@ -157,7 +165,7 @@ static char *wpp_lookup_mem(const char *filename, int type, const char *parent_n
         }
         if(parent_include == NULL)
         {
-            ERR("Parent include file missing\n");
+            ERR("Parent include %s missing.\n", debugstr_a(parent_name));
             return NULL;
         }
     }
@@ -173,6 +181,8 @@ static void *wpp_open_mem(const char *filename, int type)
     struct mem_file_desc *desc;
     HRESULT hr;
 
+    TRACE("Opening include %s.\n", debugstr_a(filename));
+
     if(!strcmp(filename, initial_filename))
     {
         current_shader.pos = 0;
@@ -184,11 +194,8 @@ static void *wpp_open_mem(const char *filename, int type)
     if(!desc)
         return NULL;
 
-    hr = ID3DInclude_Open(current_include,
-                          type ? D3D_INCLUDE_LOCAL : D3D_INCLUDE_SYSTEM,
-                          filename, parent_include, (LPCVOID *)&desc->buffer,
-                          &desc->size);
-    if(FAILED(hr))
+    if (FAILED(hr = ID3DInclude_Open(current_include, type ? D3D_INCLUDE_LOCAL : D3D_INCLUDE_SYSTEM,
+            filename, parent_include, (const void **)&desc->buffer, &desc->size)))
     {
         HeapFree(GetProcessHeap(), 0, desc);
         return NULL;
@@ -464,8 +471,8 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena
 {
     HRESULT hr;
 
-    TRACE("data %p, datasize %lu, filename %s, defines %p, include %p, sflags %#x,\n"
-            "shader %p, error_messages %p\n",
+    TRACE("data %p, datasize %lu, filename %s, defines %p, include %p, sflags %#x, "
+            "shader %p, error_messages %p.\n",
             data, datasize, debugstr_a(filename), defines, include, flags, shader, error_messages);
 
     EnterCriticalSection(&wpp_mutex);
@@ -563,7 +570,7 @@ static const struct target_info targets_info[] = {
 static const struct target_info * get_target_info(const char *target)
 {
     LONG min = 0;
-    LONG max = sizeof(targets_info) / sizeof(targets_info[0]) - 1;
+    LONG max = ARRAY_SIZE(targets_info) - 1;
     LONG cur;
     int res;
 
@@ -685,16 +692,23 @@ static HRESULT compile_shader(const char *preproc_shader, const char *target, co
     return S_OK;
 }
 
-HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename,
+HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename,
         const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
-        const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages)
+        const char *target, UINT sflags, UINT eflags, UINT secondary_flags,
+        const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader,
+        ID3DBlob **error_messages)
 {
     HRESULT hr;
 
-    TRACE("data %p, data_size %lu, filename %s, defines %p, include %p, entrypoint %s,\n"
-            "target %s, sflags %#x, eflags %#x, shader %p, error_messages %p\n",
+    TRACE("data %p, data_size %lu, filename %s, defines %p, include %p, entrypoint %s, "
+            "target %s, sflags %#x, eflags %#x, secondary_flags %#x, secondary_data %p, "
+            "secondary_data_size %lu, shader %p, error_messages %p.\n",
             data, data_size, debugstr_a(filename), defines, include, debugstr_a(entrypoint),
-            debugstr_a(target), sflags, eflags, shader, error_messages);
+            debugstr_a(target), sflags, eflags, secondary_flags, secondary_data,
+            secondary_data_size, shader, error_messages);
+
+    if (secondary_data)
+        FIXME("secondary data not implemented yet\n");
 
     if (shader) *shader = NULL;
     if (error_messages) *error_messages = NULL;
@@ -710,6 +724,19 @@ HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filena
     return hr;
 }
 
+HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename,
+        const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
+        const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages)
+{
+    TRACE("data %p, data_size %lu, filename %s, defines %p, include %p, entrypoint %s, "
+            "target %s, sflags %#x, eflags %#x, shader %p, error_messages %p.\n",
+            data, data_size, debugstr_a(filename), defines, include, debugstr_a(entrypoint),
+            debugstr_a(target), sflags, eflags, shader, error_messages);
+
+    return D3DCompile2(data, data_size, filename, defines, include, entrypoint, target, sflags,
+            eflags, 0, NULL, 0, shader, error_messages);
+}
+
 HRESULT WINAPI D3DPreprocess(const void *data, SIZE_T size, const char *filename,
         const D3D_SHADER_MACRO *defines, ID3DInclude *include,
         ID3DBlob **shader, ID3DBlob **error_messages)
@@ -756,3 +783,20 @@ HRESULT WINAPI D3DDisassemble(const void *data, SIZE_T size, UINT flags, const c
             data, size, flags, comments, disassembly);
     return E_NOTIMPL;
 }
+
+HRESULT WINAPI D3DCompileFromFile(const WCHAR *filename, const D3D_SHADER_MACRO *defines, ID3DInclude *includes,
+        const char *entrypoint, const char *target, UINT flags1, UINT flags2, ID3DBlob **code, ID3DBlob **errors)
+{
+    FIXME("filename %s, defines %p, includes %p, entrypoint %s, target %s, flags1 %x, flags2 %x, code %p, errors %p\n",
+            debugstr_w(filename), defines, includes, debugstr_a(entrypoint), debugstr_a(target), flags1, flags2, code, errors);
+
+    return E_NOTIMPL;
+}
+
+#ifndef __REACTOS__
+HRESULT WINAPI D3DLoadModule(const void *data, SIZE_T size, ID3D11Module **module)
+{
+    FIXME("data %p, size %lu, module %p stub!\n", data, size, module);
+    return E_NOTIMPL;
+}
+#endif