Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/compiler.c | 49 ++++++----------------- dlls/d3dcompiler_43/d3dcompiler_private.h | 4 +- dlls/d3dcompiler_43/hlsl.l | 14 +++---- dlls/d3dcompiler_43/hlsl.y | 10 +++-- dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 2 +- 5 files changed, 29 insertions(+), 50 deletions(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 9fc7c1d7734..78fb0c46cc0 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -752,12 +752,11 @@ static const struct target_info * get_target_info(const char *target) }
static HRESULT compile_shader(const char *preproc_shader, const char *target, const char *entrypoint, - ID3DBlob **shader_blob, ID3DBlob **error_messages) + ID3DBlob **shader, ID3DBlob **error_messages) { - struct bwriter_shader *shader; + DWORD size, major, minor; char *messages = NULL; HRESULT hr; - DWORD *res, size, major, minor; ID3DBlob *buffer; char *pos; enum shader_type shader_type; @@ -787,7 +786,7 @@ static HRESULT compile_shader(const char *preproc_shader, const char *target, co } }
- shader = parse_hlsl_shader(preproc_shader, shader_type, major, minor, entrypoint, &messages); + hr = parse_hlsl_shader(preproc_shader, shader_type, major, minor, entrypoint, shader, &messages);
if (messages) { @@ -800,14 +799,18 @@ static HRESULT compile_shader(const char *preproc_shader, const char *target, co if (error_messages) { const char *preproc_messages = *error_messages ? ID3D10Blob_GetBufferPointer(*error_messages) : NULL; + HRESULT blob_hr;
size = strlen(messages) + (preproc_messages ? strlen(preproc_messages) : 0) + 1; - hr = D3DCreateBlob(size, &buffer); - if (FAILED(hr)) + if (FAILED(blob_hr = D3DCreateBlob(size, &buffer))) { HeapFree(GetProcessHeap(), 0, messages); - if (shader) SlDeleteShader(shader); - return hr; + if (*shader) + { + ID3D10Blob_Release(*shader); + *shader = NULL; + } + return blob_hr; } pos = ID3D10Blob_GetBufferPointer(buffer); if (preproc_messages) @@ -823,35 +826,7 @@ static HRESULT compile_shader(const char *preproc_shader, const char *target, co HeapFree(GetProcessHeap(), 0, messages); }
- if (!shader) - { - ERR("HLSL shader parsing failed.\n"); - return D3DXERR_INVALIDDATA; - } - - hr = shader_write_bytecode(shader, &res, &size); - SlDeleteShader(shader); - if (FAILED(hr)) - { - ERR("Failed to write bytecode, hr %#x.\n", hr); - return D3DXERR_INVALIDDATA; - } - - if (shader_blob) - { - hr = D3DCreateBlob(size, &buffer); - if (FAILED(hr)) - { - HeapFree(GetProcessHeap(), 0, res); - return hr; - } - memcpy(ID3D10Blob_GetBufferPointer(buffer), res, size); - *shader_blob = buffer; - } - - HeapFree(GetProcessHeap(), 0, res); - - return S_OK; + return hr; }
HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename, diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index b1719ec44f7..b9e256c5754 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -1080,8 +1080,8 @@ BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN; void init_functions_tree(struct wine_rb_tree *funcs) DECLSPEC_HIDDEN; void add_function_decl(struct wine_rb_tree *funcs, char *name, struct hlsl_ir_function_decl *decl, BOOL intrinsic) DECLSPEC_HIDDEN; -struct bwriter_shader *parse_hlsl_shader(const char *text, enum shader_type type, DWORD major, DWORD minor, - const char *entrypoint, char **messages) DECLSPEC_HIDDEN; +HRESULT parse_hlsl_shader(const char *text, enum shader_type type, DWORD major, DWORD minor, + const char *entrypoint, ID3D10Blob **shader, char **messages) DECLSPEC_HIDDEN;
const char *debug_base_type(const struct hlsl_type *type) DECLSPEC_HIDDEN; const char *debug_hlsl_type(const struct hlsl_type *type) DECLSPEC_HIDDEN; diff --git a/dlls/d3dcompiler_43/hlsl.l b/dlls/d3dcompiler_43/hlsl.l index 2994c7dea62..6ffd1375970 100644 --- a/dlls/d3dcompiler_43/hlsl.l +++ b/dlls/d3dcompiler_43/hlsl.l @@ -273,20 +273,20 @@ row_major {return KW_ROW_MAJOR; }
%%
-struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD minor, - const char *entrypoint, char **messages); +HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor, + const char *entrypoint, ID3D10Blob **shader, char **messages);
-struct bwriter_shader *parse_hlsl_shader(const char *text, enum shader_type type, DWORD major, DWORD minor, - const char *entrypoint, char **messages) +HRESULT parse_hlsl_shader(const char *text, enum shader_type type, DWORD major, DWORD minor, + const char *entrypoint, ID3D10Blob **shader, char **messages) { - struct bwriter_shader *ret = NULL; YY_BUFFER_STATE buffer; + HRESULT hr;
buffer = hlsl__scan_string(text); hlsl__switch_to_buffer(buffer);
- ret = parse_hlsl(type, major, minor, entrypoint, messages); + hr = parse_hlsl(type, major, minor, entrypoint, shader, messages);
hlsl__delete_buffer(buffer); - return ret; + return hr; } diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index d3b50e3858d..e35ae7b71f0 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -2923,13 +2923,14 @@ static void compute_liveness(struct hlsl_ir_function_decl *entry_func) compute_liveness_recurse(entry_func->body, 0, 0); }
-struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD minor, - const char *entrypoint, char **messages) +HRESULT parse_hlsl(enum shader_type type, DWORD major, DWORD minor, + const char *entrypoint, ID3D10Blob **shader_blob, char **messages) { struct hlsl_ir_function_decl *entry_func; struct hlsl_scope *scope, *next_scope; struct hlsl_type *hlsl_type, *next_type; struct hlsl_ir_var *var, *next_var; + HRESULT hr = E_FAIL; unsigned int i;
hlsl_ctx.status = PARSE_SUCCESS; @@ -2979,6 +2980,9 @@ struct bwriter_shader *parse_hlsl(enum shader_type type, DWORD major, DWORD mino
compute_liveness(entry_func);
+ if (hlsl_ctx.status != PARSE_ERR) + hr = E_NOTIMPL; + out: if (messages) { @@ -3017,5 +3021,5 @@ out: free_hlsl_type(hlsl_type); }
- return NULL; + return hr; } diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c index 16d1e6dda05..673fa36fc73 100644 --- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c +++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c @@ -1112,7 +1112,7 @@ static void test_fail(void) { compiled = errors = NULL; hr = ppD3DCompile(tests[i], strlen(tests[i]), NULL, NULL, NULL, "test", targets[j], 0, 0, &compiled, &errors); - todo_wine ok(hr == E_FAIL, "Test %u, target %s, got unexpected hr %#x.\n", i, targets[j], hr); + ok(hr == E_FAIL, "Test %u, target %s, got unexpected hr %#x.\n", i, targets[j], hr); ok(!!errors, "Test %u, target %s, expected non-NULL error blob.\n", i, targets[j]); ok(!compiled, "Test %u, target %s, expected no compiled shader blob.\n", i, targets[j]); ID3D10Blob_Release(errors);