Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/hlsl.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 4f5a7b1782c..4c3e96caa0d 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -1257,7 +1257,7 @@ struct_declaration: var_modifiers struct_spec variables_def_optional ';' { if (!$2->name) { - hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR, + hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables"); } if (modifiers)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/bytecodewriter.c | 62 ++-------------------------- 1 file changed, 3 insertions(+), 59 deletions(-)
diff --git a/dlls/d3dcompiler_43/bytecodewriter.c b/dlls/d3dcompiler_43/bytecodewriter.c index 42013dfba3f..35da93fc6db 100644 --- a/dlls/d3dcompiler_43/bytecodewriter.c +++ b/dlls/d3dcompiler_43/bytecodewriter.c @@ -2327,7 +2327,8 @@ static void init_ps30_dx9_writer(struct bc_writer *writer) { writer->funcs = &ps_3_backend; }
-static struct bc_writer *create_writer(DWORD version, DWORD dxversion) { +static struct bc_writer *create_writer(DWORD version) +{ struct bc_writer *ret = d3dcompiler_alloc(sizeof(*ret));
if(!ret) { @@ -2337,101 +2338,44 @@ static struct bc_writer *create_writer(DWORD version, DWORD dxversion) {
switch(version) { case BWRITERVS_VERSION(1, 0): - if(dxversion != 9) { - WARN("Unsupported dxversion for vertex shader 1.0 requested: %u\n", dxversion); - goto fail; - } init_vs10_dx9_writer(ret); break; case BWRITERVS_VERSION(1, 1): - if(dxversion != 9) { - WARN("Unsupported dxversion for vertex shader 1.1 requested: %u\n", dxversion); - goto fail; - } init_vs11_dx9_writer(ret); break; case BWRITERVS_VERSION(2, 0): - if(dxversion != 9) { - WARN("Unsupported dxversion for vertex shader 2.0 requested: %u\n", dxversion); - goto fail; - } init_vs20_dx9_writer(ret); break; case BWRITERVS_VERSION(2, 1): - if(dxversion != 9) { - WARN("Unsupported dxversion for vertex shader 2.x requested: %u\n", dxversion); - goto fail; - } init_vs2x_dx9_writer(ret); break; case BWRITERVS_VERSION(3, 0): - if(dxversion != 9) { - WARN("Unsupported dxversion for vertex shader 3.0 requested: %u\n", dxversion); - goto fail; - } init_vs30_dx9_writer(ret); break; - case BWRITERPS_VERSION(1, 0): - if(dxversion != 9) { - WARN("Unsupported dxversion for pixel shader 1.0 requested: %u\n", dxversion); - goto fail; - } init_ps10_dx9_writer(ret); break; case BWRITERPS_VERSION(1, 1): - if(dxversion != 9) { - WARN("Unsupported dxversion for pixel shader 1.1 requested: %u\n", dxversion); - goto fail; - } init_ps11_dx9_writer(ret); break; case BWRITERPS_VERSION(1, 2): - if(dxversion != 9) { - WARN("Unsupported dxversion for pixel shader 1.2 requested: %u\n", dxversion); - goto fail; - } init_ps12_dx9_writer(ret); break; case BWRITERPS_VERSION(1, 3): - if(dxversion != 9) { - WARN("Unsupported dxversion for pixel shader 1.3 requested: %u\n", dxversion); - goto fail; - } init_ps13_dx9_writer(ret); break; case BWRITERPS_VERSION(1, 4): - if(dxversion != 9) { - WARN("Unsupported dxversion for pixel shader 1.4 requested: %u\n", dxversion); - goto fail; - } init_ps14_dx9_writer(ret); break; - case BWRITERPS_VERSION(2, 0): - if(dxversion != 9) { - WARN("Unsupported dxversion for pixel shader 2.0 requested: %u\n", dxversion); - goto fail; - } init_ps20_dx9_writer(ret); break; - case BWRITERPS_VERSION(2, 1): - if(dxversion != 9) { - WARN("Unsupported dxversion for pixel shader 2.x requested: %u\n", dxversion); - goto fail; - } init_ps2x_dx9_writer(ret); break; - case BWRITERPS_VERSION(3, 0): - if(dxversion != 9) { - WARN("Unsupported dxversion for pixel shader 3.0 requested: %u\n", dxversion); - goto fail; - } init_ps30_dx9_writer(ret); break; - default: WARN("Unexpected shader version requested: %08x\n", version); goto fail; @@ -2477,7 +2421,7 @@ HRESULT SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWOR ERR("NULL shader structure, aborting\n"); return E_FAIL; } - writer = create_writer(shader->version, dxversion); + writer = create_writer(shader->version); *result = NULL;
if(!writer) {
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/bytecodewriter.c | 2 +- dlls/d3dcompiler_43/compiler.c | 8 ++++---- dlls/d3dcompiler_43/d3dcompiler_private.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dcompiler_43/bytecodewriter.c b/dlls/d3dcompiler_43/bytecodewriter.c index 35da93fc6db..5366fa589b1 100644 --- a/dlls/d3dcompiler_43/bytecodewriter.c +++ b/dlls/d3dcompiler_43/bytecodewriter.c @@ -2410,7 +2410,7 @@ static HRESULT call_instr_handler(struct bc_writer *writer, return E_INVALIDARG; }
-HRESULT SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result, DWORD *size) +HRESULT shader_write_bytecode(const struct bwriter_shader *shader, DWORD **result, DWORD *size) { struct bc_writer *writer; struct bytecode_buffer *buffer = NULL; diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 73f8c705a00..9fc7c1d7734 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -602,11 +602,11 @@ static HRESULT assemble_shader(const char *preproc_shader, return D3DXERR_INVALIDDATA; }
- hr = SlWriteBytecode(shader, 9, &res, &size); + hr = shader_write_bytecode(shader, &res, &size); SlDeleteShader(shader); if (FAILED(hr)) { - ERR("SlWriteBytecode failed with 0x%08x\n", hr); + ERR("Failed to write bytecode, hr %#x.\n", hr); return D3DXERR_INVALIDDATA; }
@@ -829,11 +829,11 @@ static HRESULT compile_shader(const char *preproc_shader, const char *target, co return D3DXERR_INVALIDDATA; }
- hr = SlWriteBytecode(shader, 9, &res, &size); + hr = shader_write_bytecode(shader, &res, &size); SlDeleteShader(shader); if (FAILED(hr)) { - ERR("SlWriteBytecode failed with error 0x%08x.\n", hr); + ERR("Failed to write bytecode, hr %#x.\n", hr); return D3DXERR_INVALIDDATA; }
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index 1a9d68e7206..51cfc395524 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -591,7 +591,7 @@ enum bwriterdeclusage #define T3_REG 5
struct bwriter_shader *SlAssembleShader(const char *text, char **messages) DECLSPEC_HIDDEN; -HRESULT SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result, DWORD *size) DECLSPEC_HIDDEN; +HRESULT shader_write_bytecode(const struct bwriter_shader *shader, DWORD **result, DWORD *size) DECLSPEC_HIDDEN; void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN;
/* The general IR structure is inspired by Mesa GLSL hir, even though the code
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/asmparser.c | 78 +++++++++++++---------- dlls/d3dcompiler_43/asmshader.y | 8 +-- dlls/d3dcompiler_43/bytecodewriter.c | 19 +++++- dlls/d3dcompiler_43/d3dcompiler_private.h | 5 +- 4 files changed, 67 insertions(+), 43 deletions(-)
diff --git a/dlls/d3dcompiler_43/asmparser.c b/dlls/d3dcompiler_43/asmparser.c index 16e86d94dab..7a901576181 100644 --- a/dlls/d3dcompiler_43/asmparser.c +++ b/dlls/d3dcompiler_43/asmparser.c @@ -125,10 +125,9 @@ static void asmparser_dcl_input(struct asm_parser *This, DWORD usage, DWORD num, struct instruction instr;
if(!This->shader) return; - if(mod != 0 && - (This->shader->version != BWRITERPS_VERSION(3, 0) || - (mod != BWRITERSPDM_MSAMPCENTROID && - mod != BWRITERSPDM_PARTIALPRECISION))) { + if (mod && (This->shader->type != ST_PIXEL || This->shader->major_version != 3 + || (mod != BWRITERSPDM_MSAMPCENTROID && mod != BWRITERSPDM_PARTIALPRECISION))) + { asmparser_message(This, "Line %u: Unsupported modifier in dcl instruction\n", This->line_no); set_parse_status(&This->status, PARSE_ERR); return; @@ -170,10 +169,9 @@ static void asmparser_dcl_sampler(struct asm_parser *This, DWORD samptype, DWORD mod, DWORD regnum, unsigned int line_no) { if(!This->shader) return; - if(mod != 0 && - (This->shader->version != BWRITERPS_VERSION(3, 0) || - (mod != BWRITERSPDM_MSAMPCENTROID && - mod != BWRITERSPDM_PARTIALPRECISION))) { + if (mod && (This->shader->type != ST_PIXEL || This->shader->major_version != 3 + || (mod != BWRITERSPDM_MSAMPCENTROID && mod != BWRITERSPDM_PARTIALPRECISION))) + { asmparser_message(This, "Line %u: Unsupported modifier in dcl instruction\n", This->line_no); set_parse_status(&This->status, PARSE_ERR); return; @@ -503,6 +501,7 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode, DWORD mod, DW enum bwriter_comparison_type comp, const struct shader_reg *dst, const struct src_regs *srcs, int expectednsrcs) { + struct bwriter_shader *shader = This->shader; struct instruction *instr; unsigned int i; BOOL firstreg = TRUE; @@ -529,8 +528,8 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode, DWORD mod, DW switch(opcode) { case BWRITERSIO_SINCOS: /* The syntax changes between vs 2 and the other shader versions */ - if(This->shader->version == BWRITERVS_VERSION(2, 0) || - This->shader->version == BWRITERVS_VERSION(2, 1)) { + if (This->shader->type == ST_VERTEX && This->shader->major_version == 2) + { asmparser_sincos(This, mod, shift, dst, srcs); return; } @@ -538,22 +537,20 @@ static void asmparser_instr(struct asm_parser *This, DWORD opcode, DWORD mod, DW break; case BWRITERSIO_TEXCOORD: /* texcoord/texcrd are two instructions present only in PS <= 1.3 and PS 1.4 respectively */ - if(This->shader->version == BWRITERPS_VERSION(1, 4)) + if (shader->type == ST_PIXEL && shader->major_version == 1 && shader->minor_version == 4) asmparser_texcrd(This, mod, shift, dst, srcs); - else asmparser_texcoord(This, mod, shift, dst, srcs); + else + asmparser_texcoord(This, mod, shift, dst, srcs); return; case BWRITERSIO_TEX: /* this encodes both the tex PS 1.x instruction and the texld 1.4/2.0+ instruction */ - if(This->shader->version == BWRITERPS_VERSION(1, 0) || - This->shader->version == BWRITERPS_VERSION(1, 1) || - This->shader->version == BWRITERPS_VERSION(1, 2) || - This->shader->version == BWRITERPS_VERSION(1, 3)) { - asmparser_tex(This, mod, shift, dst); - return; - } - else if(This->shader->version == BWRITERPS_VERSION(1, 4)) { - asmparser_texld14(This, mod, shift, dst, srcs); + if (shader->type == ST_PIXEL && shader->major_version == 1) + { + if (shader->minor_version < 4) + asmparser_tex(This, mod, shift, dst); + else + asmparser_texld14(This, mod, shift, dst, srcs); return; } /* else fallback to the standard behavior */ @@ -1355,7 +1352,8 @@ void create_vs10_parser(struct asm_parser *ret) { }
ret->shader->type = ST_VERTEX; - ret->shader->version = BWRITERVS_VERSION(1, 0); + ret->shader->major_version = 1; + ret->shader->minor_version = 0; ret->funcs = &parser_vs_1; gen_oldvs_output(ret->shader); } @@ -1371,7 +1369,8 @@ void create_vs11_parser(struct asm_parser *ret) { }
ret->shader->type = ST_VERTEX; - ret->shader->version = BWRITERVS_VERSION(1, 1); + ret->shader->major_version = 1; + ret->shader->minor_version = 1; ret->funcs = &parser_vs_1; gen_oldvs_output(ret->shader); } @@ -1387,7 +1386,8 @@ void create_vs20_parser(struct asm_parser *ret) { }
ret->shader->type = ST_VERTEX; - ret->shader->version = BWRITERVS_VERSION(2, 0); + ret->shader->major_version = 2; + ret->shader->minor_version = 0; ret->funcs = &parser_vs_2; gen_oldvs_output(ret->shader); } @@ -1403,7 +1403,8 @@ void create_vs2x_parser(struct asm_parser *ret) { }
ret->shader->type = ST_VERTEX; - ret->shader->version = BWRITERVS_VERSION(2, 1); + ret->shader->major_version = 2; + ret->shader->minor_version = 1; ret->funcs = &parser_vs_2; gen_oldvs_output(ret->shader); } @@ -1419,7 +1420,8 @@ void create_vs30_parser(struct asm_parser *ret) { }
ret->shader->type = ST_VERTEX; - ret->shader->version = BWRITERVS_VERSION(3, 0); + ret->shader->major_version = 3; + ret->shader->minor_version = 0; ret->funcs = &parser_vs_3; }
@@ -1434,7 +1436,8 @@ void create_ps10_parser(struct asm_parser *ret) { }
ret->shader->type = ST_PIXEL; - ret->shader->version = BWRITERPS_VERSION(1, 0); + ret->shader->major_version = 1; + ret->shader->minor_version = 0; ret->funcs = &parser_ps_1_0123; gen_oldps_input(ret->shader, 4); } @@ -1450,7 +1453,8 @@ void create_ps11_parser(struct asm_parser *ret) { }
ret->shader->type = ST_PIXEL; - ret->shader->version = BWRITERPS_VERSION(1, 1); + ret->shader->major_version = 1; + ret->shader->minor_version = 1; ret->funcs = &parser_ps_1_0123; gen_oldps_input(ret->shader, 4); } @@ -1466,7 +1470,8 @@ void create_ps12_parser(struct asm_parser *ret) { }
ret->shader->type = ST_PIXEL; - ret->shader->version = BWRITERPS_VERSION(1, 2); + ret->shader->major_version = 1; + ret->shader->minor_version = 2; ret->funcs = &parser_ps_1_0123; gen_oldps_input(ret->shader, 4); } @@ -1482,7 +1487,8 @@ void create_ps13_parser(struct asm_parser *ret) { }
ret->shader->type = ST_PIXEL; - ret->shader->version = BWRITERPS_VERSION(1, 3); + ret->shader->major_version = 1; + ret->shader->minor_version = 3; ret->funcs = &parser_ps_1_0123; gen_oldps_input(ret->shader, 4); } @@ -1498,7 +1504,8 @@ void create_ps14_parser(struct asm_parser *ret) { }
ret->shader->type = ST_PIXEL; - ret->shader->version = BWRITERPS_VERSION(1, 4); + ret->shader->major_version = 1; + ret->shader->minor_version = 4; ret->funcs = &parser_ps_1_4; gen_oldps_input(ret->shader, 6); } @@ -1514,7 +1521,8 @@ void create_ps20_parser(struct asm_parser *ret) { }
ret->shader->type = ST_PIXEL; - ret->shader->version = BWRITERPS_VERSION(2, 0); + ret->shader->major_version = 2; + ret->shader->minor_version = 0; ret->funcs = &parser_ps_2; gen_oldps_input(ret->shader, 8); } @@ -1530,7 +1538,8 @@ void create_ps2x_parser(struct asm_parser *ret) { }
ret->shader->type = ST_PIXEL; - ret->shader->version = BWRITERPS_VERSION(2, 1); + ret->shader->major_version = 2; + ret->shader->minor_version = 1; ret->funcs = &parser_ps_2_x; gen_oldps_input(ret->shader, 8); } @@ -1546,6 +1555,7 @@ void create_ps30_parser(struct asm_parser *ret) { }
ret->shader->type = ST_PIXEL; - ret->shader->version = BWRITERPS_VERSION(3, 0); + ret->shader->major_version = 3; + ret->shader->minor_version = 0; ret->funcs = &parser_ps_3; } diff --git a/dlls/d3dcompiler_43/asmshader.y b/dlls/d3dcompiler_43/asmshader.y index 1b7a07313fc..9e0fec618cd 100644 --- a/dlls/d3dcompiler_43/asmshader.y +++ b/dlls/d3dcompiler_43/asmshader.y @@ -591,8 +591,8 @@ instruction: INSTR_ADD omods dreg ',' sregs asm_ctx.line_no); set_parse_status(&asm_ctx.status, PARSE_ERR); } - if(asm_ctx.shader->version == BWRITERPS_VERSION(2, 0) || - asm_ctx.shader->version == BWRITERPS_VERSION(2, 1)) { + if (asm_ctx.shader->type == ST_PIXEL && asm_ctx.shader->major_version == 2) + { asmparser_message(&asm_ctx, "Line %u: Declaration not supported in PS 2\n", asm_ctx.line_no); set_parse_status(&asm_ctx.status, PARSE_ERR); @@ -614,8 +614,8 @@ instruction: INSTR_ADD omods dreg ',' sregs asm_ctx.line_no); set_parse_status(&asm_ctx.status, PARSE_ERR); } - if(asm_ctx.shader->version == BWRITERPS_VERSION(2, 0) || - asm_ctx.shader->version == BWRITERPS_VERSION(2, 1)) { + if (asm_ctx.shader->type == ST_PIXEL && asm_ctx.shader->major_version == 2) + { asmparser_message(&asm_ctx, "Line %u: Declaration not supported in PS 2\n", asm_ctx.line_no); set_parse_status(&asm_ctx.status, PARSE_ERR); diff --git a/dlls/d3dcompiler_43/bytecodewriter.c b/dlls/d3dcompiler_43/bytecodewriter.c index 5366fa589b1..8b016cd6201 100644 --- a/dlls/d3dcompiler_43/bytecodewriter.c +++ b/dlls/d3dcompiler_43/bytecodewriter.c @@ -340,6 +340,21 @@ static void put_dword(struct bytecode_buffer *buffer, DWORD value) { }
/* bwriter -> d3d9 conversion functions. */ + +static DWORD sm1_version(const struct bwriter_shader *shader) +{ + switch (shader->type) + { + case ST_VERTEX: + return D3DVS_VERSION(shader->major_version, shader->minor_version); + case ST_PIXEL: + return D3DPS_VERSION(shader->major_version, shader->minor_version); + default: + ERR("Invalid shader type %#x.\n", shader->type); + return 0; + } +} + static DWORD d3d9_swizzle(DWORD bwriter_swizzle) { DWORD ret = 0; @@ -2421,7 +2436,7 @@ HRESULT shader_write_bytecode(const struct bwriter_shader *shader, DWORD **resul ERR("NULL shader structure, aborting\n"); return E_FAIL; } - writer = create_writer(shader->version); + writer = create_writer(sm1_version(shader)); *result = NULL;
if(!writer) { @@ -2439,7 +2454,7 @@ HRESULT shader_write_bytecode(const struct bwriter_shader *shader, DWORD **resul }
/* Write shader type and version */ - put_dword(buffer, shader->version); + put_dword(buffer, sm1_version(shader));
writer->funcs->header(writer, shader, buffer); if(FAILED(writer->state)) { diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index 51cfc395524..9596c2b6b1e 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -35,6 +35,7 @@ #include "d3dcompiler.h"
#include <assert.h> +#include <stdint.h>
/* * This doesn't belong here, but for some functions it is possible to return that value, @@ -118,9 +119,7 @@ struct samplerdecl { #define INSTRARRAY_INITIAL_SIZE 8 struct bwriter_shader { enum shader_type type; - - /* Shader version selected */ - DWORD version; + uint8_t major_version, minor_version;
/* Local constants. Every constant that is not defined below is loaded from * the global constant set at shader runtime
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d10/d3d10_private.h | 12 ++++++ dlls/d3d10/effect.c | 84 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index e02ea376bb6..21d7f964e8f 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -81,6 +81,15 @@ struct d3d10_effect_object } object; };
+struct d3d10_effect_shader_resource +{ + D3D10_SHADER_INPUT_TYPE in_type; + unsigned int bind_point; + unsigned int bind_count; + + struct d3d10_effect_variable *variable; +}; + struct d3d10_effect_shader_signature { char *signature; @@ -99,6 +108,9 @@ struct d3d10_effect_shader_variable ID3D10PixelShader *ps; ID3D10GeometryShader *gs; } shader; + + unsigned int resource_count; + struct d3d10_effect_shader_resource *resources; };
struct d3d10_effect_state_object_variable diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 8cc2d11feb6..2360e5a0259 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -656,6 +656,84 @@ static HRESULT shader_chunk_handler(const char *data, DWORD data_size, DWORD tag return S_OK; }
+static HRESULT get_fx10_shader_resources(struct d3d10_effect_variable *v, const void *data, size_t data_size) +{ + struct d3d10_effect_shader_variable *sv = &v->u.shader; + struct d3d10_effect_shader_resource *sr; + D3D10_SHADER_INPUT_BIND_DESC bind_desc; + ID3D10ShaderReflection *reflection; + struct d3d10_effect_variable *var; + D3D10_SHADER_DESC desc; + unsigned int i, y; + HRESULT hr; + + if (FAILED(hr = D3D10ReflectShader(data, data_size, &reflection))) + return hr; + + reflection->lpVtbl->GetDesc(reflection, &desc); + sv->resource_count = desc.BoundResources; + + if (!(sv->resources = heap_calloc(sv->resource_count, sizeof(*sv->resources)))) + { + ERR("Failed to allocate shader resource binding information memory.\n"); + reflection->lpVtbl->Release(reflection); + return E_OUTOFMEMORY; + } + + for (i = 0; i < desc.BoundResources; ++i) + { + reflection->lpVtbl->GetResourceBindingDesc(reflection, i, &bind_desc); + sr = &sv->resources[i]; + + sr->in_type = bind_desc.Type; + sr->bind_point = bind_desc.BindPoint; + sr->bind_count = bind_desc.BindCount; + + switch (bind_desc.Type) + { + case D3D10_SIT_CBUFFER: + case D3D10_SIT_TBUFFER: + for (y = 0; y < v->effect->local_buffer_count; ++y) + { + var = &v->effect->local_buffers[y]; + + if (!strcmp(bind_desc.Name, var->name)) + { + sr->variable = var; + break; + } + } + break; + + case D3D10_SIT_SAMPLER: + case D3D10_SIT_TEXTURE: + for (y = 0; y < v->effect->local_variable_count; ++y) + { + var = &v->effect->local_variables[y]; + + if (!strcmp(bind_desc.Name, var->name)) + { + sr->variable = var; + break; + } + } + break; + + default: + break; + } + + if (!sr->variable) + { + WARN("Failed to find shader resource.\n"); + reflection->lpVtbl->Release(reflection); + return E_FAIL; + } + } + + return S_OK; +} + static HRESULT parse_fx10_shader(const char *data, size_t data_size, DWORD offset, struct d3d10_effect_variable *v) { ID3D10Device *device = v->effect->device; @@ -691,6 +769,9 @@ static HRESULT parse_fx10_shader(const char *data, size_t data_size, DWORD offse /* We got a shader VertexShader vs = NULL, so it is fine to skip this. */ if (!dxbc_size) return S_OK;
+ if (FAILED(hr = get_fx10_shader_resources(v, ptr, dxbc_size))) + return hr; + switch (v->type->basetype) { case D3D10_SVT_VERTEXSHADER: @@ -2623,6 +2704,9 @@ static void d3d10_effect_shader_variable_destroy(struct d3d10_effect_shader_vari FIXME("Unhandled shader type %s.\n", debug_d3d10_shader_variable_type(type)); break; } + + if (s->resource_count) + heap_free(s->resources); }
static void d3d10_effect_variable_destroy(struct d3d10_effect_variable *v)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/d3dcompiler_43/bytecodewriter.c | 30 ++++++++++++++--------- dlls/d3dcompiler_43/d3dcompiler_private.h | 3 +-- 2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/dlls/d3dcompiler_43/bytecodewriter.c b/dlls/d3dcompiler_43/bytecodewriter.c index 8b016cd6201..add9804cac0 100644 --- a/dlls/d3dcompiler_43/bytecodewriter.c +++ b/dlls/d3dcompiler_43/bytecodewriter.c @@ -939,7 +939,8 @@ static void vs_12_dstreg(struct bc_writer *This, const struct shader_reg *reg, break;
case BWRITERSPR_PREDICATE: - if(This->version != BWRITERVS_VERSION(2, 1)){ + if (This->shader->minor_version == 0) + { WARN("Predicate register is allowed only in vs_2_x\n"); This->state = E_INVALIDARG; return; @@ -1634,7 +1635,8 @@ static void vs_2_srcreg(struct bc_writer *This, break;
case BWRITERSPR_PREDICATE: - if(This->version != BWRITERVS_VERSION(2, 1)){ + if (This->shader->minor_version == 0) + { WARN("Predicate register is allowed only in vs_2_x\n"); This->state = E_INVALIDARG; return; @@ -1871,7 +1873,8 @@ static void ps_2_srcreg(struct bc_writer *This, break;
case BWRITERSPR_PREDICATE: - if(This->version != BWRITERPS_VERSION(2, 1)){ + if (This->shader->minor_version == 0) + { WARN("Predicate register not supported in ps_2_0\n"); This->state = E_INVALIDARG; } @@ -1917,7 +1920,8 @@ static void ps_2_0_dstreg(struct bc_writer *This, break;
case BWRITERSPR_PREDICATE: - if(This->version != BWRITERPS_VERSION(2, 1)){ + if (This->shader->minor_version == 0) + { WARN("Predicate register not supported in ps_2_0\n"); This->state = E_INVALIDARG; } @@ -2072,6 +2076,7 @@ static void sm_3_header(struct bc_writer *This, const struct bwriter_shader *sha static void sm_3_srcreg(struct bc_writer *This, const struct shader_reg *reg, struct bytecode_buffer *buffer) { + const struct bwriter_shader *shader = This->shader; DWORD token = (1u << 31); /* Bit 31 of registers is 1 */ DWORD d3d9reg;
@@ -2081,14 +2086,16 @@ static void sm_3_srcreg(struct bc_writer *This, token |= d3d9_srcmod(reg->srcmod);
if(reg->rel_reg) { - if(reg->type == BWRITERSPR_CONST && This->version == BWRITERPS_VERSION(3, 0)) { + if (reg->type == BWRITERSPR_CONST && shader->type == ST_PIXEL && shader->major_version == 3) + { WARN("c%u[...] is unsupported in ps_3_0\n", reg->regnum); This->state = E_INVALIDARG; return; } - if(((reg->rel_reg->type == BWRITERSPR_ADDR && This->version == BWRITERVS_VERSION(3, 0)) || - reg->rel_reg->type == BWRITERSPR_LOOP) && - reg->rel_reg->regnum == 0) { + + if (((reg->rel_reg->type == BWRITERSPR_ADDR && shader->type == ST_VERTEX && shader->major_version == 3) + || reg->rel_reg->type == BWRITERSPR_LOOP) && reg->rel_reg->regnum == 0) + { token |= D3DVS_ADDRMODE_RELATIVE & D3DVS_ADDRESSMODE_MASK; } else { WARN("Unsupported relative addressing register\n"); @@ -2111,12 +2118,13 @@ static void sm_3_dstreg(struct bc_writer *This, const struct shader_reg *reg, struct bytecode_buffer *buffer, DWORD shift, DWORD mod) { + const struct bwriter_shader *shader = This->shader; DWORD token = (1u << 31); /* Bit 31 of registers is 1 */ DWORD d3d9reg;
if(reg->rel_reg) { - if(This->version == BWRITERVS_VERSION(3, 0) && - reg->type == BWRITERSPR_OUTPUT) { + if (shader->type == ST_VERTEX && shader->major_version == 3 && reg->type == BWRITERSPR_OUTPUT) + { token |= D3DVS_ADDRMODE_RELATIVE & D3DVS_ADDRESSMODE_MASK; } else { WARN("Relative addressing not supported for this shader type or register type\n"); @@ -2395,7 +2403,6 @@ static struct bc_writer *create_writer(DWORD version) WARN("Unexpected shader version requested: %08x\n", version); goto fail; } - ret->version = version; return ret;
fail: @@ -2437,6 +2444,7 @@ HRESULT shader_write_bytecode(const struct bwriter_shader *shader, DWORD **resul return E_FAIL; } writer = create_writer(sm1_version(shader)); + writer->shader = shader; *result = NULL;
if(!writer) { diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index 9596c2b6b1e..0a2319dbbec 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -333,12 +333,11 @@ struct bytecode_backend { /* Bytecode writing stuff */ struct bc_writer { const struct bytecode_backend *funcs; + const struct bwriter_shader *shader;
/* Avoid result checking */ HRESULT state;
- DWORD version; - /* Vertex shader varying mapping */ DWORD oPos_regnum; DWORD oD_regnum[2];
On Fri, Mar 20, 2020 at 12:08 AM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
dlls/d3dcompiler_43/bytecodewriter.c | 30 ++++++++++++++--------- dlls/d3dcompiler_43/d3dcompiler_private.h | 3 +-- 2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/dlls/d3dcompiler_43/bytecodewriter.c b/dlls/d3dcompiler_43/bytecodewriter.c index 8b016cd6201..add9804cac0 100644 --- a/dlls/d3dcompiler_43/bytecodewriter.c +++ b/dlls/d3dcompiler_43/bytecodewriter.c @@ -939,7 +939,8 @@ static void vs_12_dstreg(struct bc_writer *This, const struct shader_reg *reg, break;
case BWRITERSPR_PREDICATE:
if(This->version != BWRITERVS_VERSION(2, 1)){
if (This->shader->minor_version == 0)
{ WARN("Predicate register is allowed only in vs_2_x\n"); This->state = E_INVALIDARG; return;
This function is also used for vs_1_* so, technically, this should check major version too.
Signed-off-by: Liam Middlebrook lmiddlebrook@nvidia.com
On 3/19/20 4:07 PM, Zebediah Figura wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
dlls/d3dcompiler_43/hlsl.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index 4f5a7b1782c..4c3e96caa0d 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -1257,7 +1257,7 @@ struct_declaration: var_modifiers struct_spec variables_def_optional ';' { if (!$2->name) {
hlsl_report_message(get_location(&@1), HLSL_LEVEL_ERROR,
hlsl_report_message(get_location(&@2), HLSL_LEVEL_ERROR, "anonymous struct declaration with no variables"); } if (modifiers)
----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -----------------------------------------------------------------------------------