2013/5/2 Christian Costa titan.costa@gmail.com:
dlls/d3dcompiler_43/compiler.c | 101 +++++++++++++++++++++++------ dlls/d3dcompiler_43/d3dcompiler_private.h | 1 2 files changed, 81 insertions(+), 21 deletions(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 4942985..a6a9867 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -490,6 +490,66 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena return hr; }
+struct {
Please make it static const.
- const char *name;
- enum shader_type type;
- DWORD sm_major;
- DWORD sm_minor;
- DWORD level_major;
- DWORD level_minor;
- BOOL sw;
- BOOL support;
+} targets_info[] = {
- /* SM 1 */
- { "vs_1_0", ST_VERTEX, 1, 0, 0, 0, FALSE, TRUE },
- { "vs_1_1", ST_VERTEX, 1, 1, 0, 0, FALSE, TRUE },
- { "ps_1_0", ST_PIXEL, 1, 0, 0, 0, FALSE, TRUE },
- { "ps_1_1", ST_PIXEL, 1, 1, 0, 0, FALSE, FALSE },
- { "ps_1_2", ST_PIXEL, 1, 2, 0, 0, FALSE, FALSE },
- { "ps_1_3", ST_PIXEL, 1, 3, 0, 0, FALSE, FALSE },
- { "ps_1_4", ST_PIXEL, 1, 4, 0, 0, FALSE, FALSE },
- { "tx_1_0", ST_UNKNOWN, 1, 0, 0, 0, FALSE, FALSE },
- /* SM 2 */
- { "vs_2_0", ST_VERTEX, 2, 0, 0, 0, FALSE, TRUE },
- { "vs_2_a", ST_VERTEX, 2, 1, 0, 0, FALSE, FALSE },
- { "vs_2_sw", ST_VERTEX, 2, 0, 0, 0, TRUE, FALSE },
- { "ps_2_0", ST_PIXEL, 2, 0, 0, 0, FALSE, TRUE },
- { "ps_2_a", ST_PIXEL, 2, 1, 0, 0, FALSE, FALSE },
- { "ps_2_b", ST_PIXEL, 2, 2, 0, 0, FALSE, FALSE },
- { "ps_2_sw", ST_PIXEL, 2, 0, 0, 0, TRUE, FALSE },
- { "fx_2_0", ST_UNKNOWN, 2, 0, 0, 0, FALSE, FALSE },
- /* SM 3 */
- { "vs_3_0", ST_VERTEX, 3, 0, 0, 0, FALSE, TRUE },
- { "vs_3_sw", ST_VERTEX, 3, 0, 0, 0, TRUE, FALSE },
- { "ps_3_0", ST_PIXEL, 3, 0, 0, 0, FALSE, TRUE },
- { "ps_3_sw", ST_PIXEL, 3, 0, 0, 0, TRUE, FALSE },
- /* SM 4 */
- { "vs_4_0_level_9_0", ST_VERTEX, 4, 0, 9, 0, FALSE, FALSE },
- { "vs_4_0_level_9_1", ST_VERTEX, 4, 0, 9, 1, FALSE, FALSE },
- { "vs_4_0_level_9_3", ST_VERTEX, 4, 0, 9, 3, FALSE, FALSE },
- { "vs_4_0", ST_VERTEX, 4, 0, 0, 0, FALSE, TRUE },
- { "vs_4_1", ST_VERTEX, 4, 1, 0, 0, FALSE, TRUE },
- { "ps_4_0_level_9_0", ST_PIXEL, 4, 0, 9, 0, FALSE, FALSE },
- { "ps_4_0_level_9_1", ST_PIXEL, 4, 0, 9, 1, FALSE, FALSE },
- { "ps_4_0_level_9_3", ST_PIXEL, 4, 0, 9, 3, FALSE, FALSE },
- { "ps_4_0", ST_PIXEL, 4, 0, 0, 0, FALSE, TRUE },
- { "ps_4_1", ST_PIXEL, 4, 1, 0, 0, FALSE, TRUE },
- { "gs_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
- { "gs_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
- { "cs_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
- { "cs_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
- { "fx_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
- { "fx_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
- /* SM 5 */
- { "vs_5_0", ST_VERTEX, 5, 0, 0, 0, FALSE, TRUE },
- { "ps_5_0", ST_PIXEL, 5, 0, 0, 0, FALSE, TRUE },
- { "hs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
- { "gs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
- { "ds_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
- { "cs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
- { "fx_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
+};
static HRESULT compile_shader(const char *preproc_shader, const char *target, const char *entrypoint, ID3DBlob **shader_blob, ID3DBlob **error_messages) { @@ -500,38 +560,37 @@ static HRESULT compile_shader(const char *preproc_shader, const char *target, co ID3DBlob *buffer; char *pos; enum shader_type shader_type;
ULONG i;
ULONG nb = sizeof(targets_info) / sizeof(targets_info[0]);
TRACE("Preprocessed shader source: %s\n", debugstr_a(preproc_shader));
TRACE("Parsing compilation target %s.\n", debugstr_a(target));
- if (strlen(target) != 6 || target[1] != 's' || target[2] != '_' || target[4] != '_')
- for (i = 0; i < nb; i++) {
FIXME("Unknown compilation target %s.\n", debugstr_a(target));
return D3DERR_INVALIDCALL;
if (!strcmp(target, targets_info[i].name))
{
if (!targets_info[i].support)
{
FIXME("Compilation target %s not yet supported\n", debugstr_a(target));
return D3DERR_INVALIDCALL;
}
else
{
shader_type = targets_info[i].type;
major = targets_info[i].sm_major;
minor = targets_info[i].sm_minor;
break;
}
}}
- if (target[0] == 'v')
shader_type = ST_VERTEX;
- else if (target[0] == 'p')
shader_type = ST_PIXEL;
- else
- if (i == nb) {
FIXME("Unsupported shader target type %s.\n", debugstr_a(target));
}FIXME("Unknown compilation target %s\n", debugstr_a(target)); return D3DERR_INVALIDCALL;
major = target[3] - '0';
if (major == 0 || major > 5)
{
FIXME("Unsupported shader target major version %d.\n", major);
return D3DERR_INVALIDCALL;
}
minor = target[5] - '0';
if (minor > 1 || (minor == 1 && (shader_type != ST_VERTEX || major > 1)))
{
FIXME("Unsupported shader target minor version %d.\n", minor);
return D3DERR_INVALIDCALL;
} shader = parse_hlsl_shader(preproc_shader, shader_type, major, minor, entrypoint, &messages);
if (messages)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index c8a92f1..63745e0 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -51,6 +51,7 @@ enum shader_type { ST_VERTEX, ST_PIXEL,
- ST_UNKNOWN
};
I'd prefer ST_UNKNOWN to be in the first place here (so that it doesn't get pushed down when we'll add more target types) but it's not a big deal.
typedef enum BWRITER_COMPARISON_TYPE {
The patch is probably fine otherwise but can you check that targets in the form "vs.1.0" aren't accepted by native D3DCompile? I suppose those tokens are assembler-only, but better be safe than sorry.
2013/5/3 Matteo Bruni matteo.mystral@gmail.com
2013/5/2 Christian Costa titan.costa@gmail.com:
dlls/d3dcompiler_43/compiler.c | 101
+++++++++++++++++++++++------
dlls/d3dcompiler_43/d3dcompiler_private.h | 1 2 files changed, 81 insertions(+), 21 deletions(-)
diff --git a/dlls/d3dcompiler_43/compiler.c
b/dlls/d3dcompiler_43/compiler.c
index 4942985..a6a9867 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -490,6 +490,66 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T
datasize, const char *filena
return hr;
}
+struct {
Please make it static const.
- const char *name;
- enum shader_type type;
- DWORD sm_major;
- DWORD sm_minor;
- DWORD level_major;
- DWORD level_minor;
- BOOL sw;
- BOOL support;
+} targets_info[] = {
- /* SM 1 */
- { "vs_1_0", ST_VERTEX, 1, 0, 0, 0, FALSE, TRUE },
- { "vs_1_1", ST_VERTEX, 1, 1, 0, 0, FALSE, TRUE },
- { "ps_1_0", ST_PIXEL, 1, 0, 0, 0, FALSE, TRUE },
- { "ps_1_1", ST_PIXEL, 1, 1, 0, 0, FALSE, FALSE },
- { "ps_1_2", ST_PIXEL, 1, 2, 0, 0, FALSE, FALSE },
- { "ps_1_3", ST_PIXEL, 1, 3, 0, 0, FALSE, FALSE },
- { "ps_1_4", ST_PIXEL, 1, 4, 0, 0, FALSE, FALSE },
- { "tx_1_0", ST_UNKNOWN, 1, 0, 0, 0, FALSE, FALSE },
- /* SM 2 */
- { "vs_2_0", ST_VERTEX, 2, 0, 0, 0, FALSE, TRUE },
- { "vs_2_a", ST_VERTEX, 2, 1, 0, 0, FALSE, FALSE },
- { "vs_2_sw", ST_VERTEX, 2, 0, 0, 0, TRUE, FALSE },
- { "ps_2_0", ST_PIXEL, 2, 0, 0, 0, FALSE, TRUE },
- { "ps_2_a", ST_PIXEL, 2, 1, 0, 0, FALSE, FALSE },
- { "ps_2_b", ST_PIXEL, 2, 2, 0, 0, FALSE, FALSE },
- { "ps_2_sw", ST_PIXEL, 2, 0, 0, 0, TRUE, FALSE },
- { "fx_2_0", ST_UNKNOWN, 2, 0, 0, 0, FALSE, FALSE },
- /* SM 3 */
- { "vs_3_0", ST_VERTEX, 3, 0, 0, 0, FALSE, TRUE },
- { "vs_3_sw", ST_VERTEX, 3, 0, 0, 0, TRUE, FALSE },
- { "ps_3_0", ST_PIXEL, 3, 0, 0, 0, FALSE, TRUE },
- { "ps_3_sw", ST_PIXEL, 3, 0, 0, 0, TRUE, FALSE },
- /* SM 4 */
- { "vs_4_0_level_9_0", ST_VERTEX, 4, 0, 9, 0, FALSE, FALSE },
- { "vs_4_0_level_9_1", ST_VERTEX, 4, 0, 9, 1, FALSE, FALSE },
- { "vs_4_0_level_9_3", ST_VERTEX, 4, 0, 9, 3, FALSE, FALSE },
- { "vs_4_0", ST_VERTEX, 4, 0, 0, 0, FALSE, TRUE },
- { "vs_4_1", ST_VERTEX, 4, 1, 0, 0, FALSE, TRUE },
- { "ps_4_0_level_9_0", ST_PIXEL, 4, 0, 9, 0, FALSE, FALSE },
- { "ps_4_0_level_9_1", ST_PIXEL, 4, 0, 9, 1, FALSE, FALSE },
- { "ps_4_0_level_9_3", ST_PIXEL, 4, 0, 9, 3, FALSE, FALSE },
- { "ps_4_0", ST_PIXEL, 4, 0, 0, 0, FALSE, TRUE },
- { "ps_4_1", ST_PIXEL, 4, 1, 0, 0, FALSE, TRUE },
- { "gs_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
- { "gs_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
- { "cs_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
- { "cs_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
- { "fx_4_0", ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
- { "fx_4_1", ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
- /* SM 5 */
- { "vs_5_0", ST_VERTEX, 5, 0, 0, 0, FALSE, TRUE },
- { "ps_5_0", ST_PIXEL, 5, 0, 0, 0, FALSE, TRUE },
- { "hs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
- { "gs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
- { "ds_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
- { "cs_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
- { "fx_5_0", ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
+};
static HRESULT compile_shader(const char *preproc_shader, const char
*target, const char *entrypoint,
ID3DBlob **shader_blob, ID3DBlob **error_messages)
{ @@ -500,38 +560,37 @@ static HRESULT compile_shader(const char
*preproc_shader, const char *target, co
ID3DBlob *buffer; char *pos; enum shader_type shader_type;
ULONG i;
ULONG nb = sizeof(targets_info) / sizeof(targets_info[0]);
TRACE("Preprocessed shader source: %s\n",
debugstr_a(preproc_shader));
TRACE("Parsing compilation target %s.\n", debugstr_a(target));
- if (strlen(target) != 6 || target[1] != 's' || target[2] != '_' ||
target[4] != '_')
- for (i = 0; i < nb; i++) {
FIXME("Unknown compilation target %s.\n", debugstr_a(target));
return D3DERR_INVALIDCALL;
if (!strcmp(target, targets_info[i].name))
{
if (!targets_info[i].support)
{
FIXME("Compilation target %s not yet supported\n",
debugstr_a(target));
return D3DERR_INVALIDCALL;
}
else
{
shader_type = targets_info[i].type;
major = targets_info[i].sm_major;
minor = targets_info[i].sm_minor;
break;
}
}}
- if (target[0] == 'v')
shader_type = ST_VERTEX;
- else if (target[0] == 'p')
shader_type = ST_PIXEL;
- else
- if (i == nb) {
FIXME("Unsupported shader target type %s.\n",
debugstr_a(target));
}FIXME("Unknown compilation target %s\n", debugstr_a(target)); return D3DERR_INVALIDCALL;
- major = target[3] - '0';
- if (major == 0 || major > 5)
- {
FIXME("Unsupported shader target major version %d.\n", major);
return D3DERR_INVALIDCALL;
- }
- minor = target[5] - '0';
- if (minor > 1 || (minor == 1 && (shader_type != ST_VERTEX || major
1)))
- {
FIXME("Unsupported shader target minor version %d.\n", minor);
return D3DERR_INVALIDCALL;
- } shader = parse_hlsl_shader(preproc_shader, shader_type, major,
minor, entrypoint, &messages);
if (messages)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h
b/dlls/d3dcompiler_43/d3dcompiler_private.h
index c8a92f1..63745e0 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -51,6 +51,7 @@ enum shader_type { ST_VERTEX, ST_PIXEL,
- ST_UNKNOWN
};
I'd prefer ST_UNKNOWN to be in the first place here (so that it doesn't get pushed down when we'll add more target types) but it's not a big deal.
Make sense.
typedef enum BWRITER_COMPARISON_TYPE {
The patch is probably fine otherwise but can you check that targets in the form "vs.1.0" aren't accepted by native D3DCompile? I suppose those tokens are assembler-only, but better be safe than sorry.
Just tested.The dot syntax is supported until SM 3.0 included for all targets except for fx_2_0 and ps_3_sw. It's seem the syntax has been dropped for SM 4.0 and above. Note that the asm code generated use always the v/ps_x_y syntax.
I will add an altername name to support that. Thanks.
Christian