[PATCH] d3dcompiler: Add a LUT to find compilation targets info. (try 3)
Christian Costa
titan.costa at gmail.com
Wed May 8 00:31:35 CDT 2013
Try 3:
- rename nb to nb_targets
Try 2:
- Add alterate names for targets using dots syntax + make array const
---
dlls/d3dcompiler_43/compiler.c | 103 +++++++++++++++++++++++------
dlls/d3dcompiler_43/d3dcompiler_private.h | 3 +
2 files changed, 84 insertions(+), 22 deletions(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c
index 4942985..98a82a4 100644
--- a/dlls/d3dcompiler_43/compiler.c
+++ b/dlls/d3dcompiler_43/compiler.c
@@ -490,6 +490,67 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena
return hr;
}
+static const struct {
+ const char *name;
+ const char *altname;
+ 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", "vs.1.0", ST_VERTEX, 1, 0, 0, 0, FALSE, TRUE },
+ { "vs_1_1", "vs.1.1", ST_VERTEX, 1, 1, 0, 0, FALSE, TRUE },
+ { "ps_1_0", "ps.1.0", ST_PIXEL, 1, 0, 0, 0, FALSE, TRUE },
+ { "ps_1_1", "ps.1.1", ST_PIXEL, 1, 1, 0, 0, FALSE, FALSE },
+ { "ps_1_2", "ps.1.2", ST_PIXEL, 1, 2, 0, 0, FALSE, FALSE },
+ { "ps_1_3", "ps.1.3", ST_PIXEL, 1, 3, 0, 0, FALSE, FALSE },
+ { "ps_1_4", "ps.1.4", ST_PIXEL, 1, 4, 0, 0, FALSE, FALSE },
+ { "tx_1_0", NULL, ST_UNKNOWN, 1, 0, 0, 0, FALSE, FALSE },
+ /* SM 2 */
+ { "vs_2_0", "vs.2.0", ST_VERTEX, 2, 0, 0, 0, FALSE, TRUE },
+ { "vs_2_a", "vs.2.a", ST_VERTEX, 2, 1, 0, 0, FALSE, FALSE },
+ { "vs_2_sw", "vs.2.sw", ST_VERTEX, 2, 0, 0, 0, TRUE, FALSE },
+ { "ps_2_0", "ps.2.0", ST_PIXEL, 2, 0, 0, 0, FALSE, TRUE },
+ { "ps_2_a", "ps.2.a", ST_PIXEL, 2, 1, 0, 0, FALSE, FALSE },
+ { "ps_2_b", "ps.2.b", ST_PIXEL, 2, 2, 0, 0, FALSE, FALSE },
+ { "ps_2_sw", "ps.2.sw", ST_PIXEL, 2, 0, 0, 0, TRUE, FALSE },
+ { "fx_2_0", NULL, ST_UNKNOWN, 2, 0, 0, 0, FALSE, FALSE },
+ /* SM 3 */
+ { "vs_3_0", "vs.3.0" , ST_VERTEX, 3, 0, 0, 0, FALSE, TRUE },
+ { "vs_3_sw", "vs.3.sw", ST_VERTEX, 3, 0, 0, 0, TRUE, FALSE },
+ { "ps_3_0", "ps.3.0", ST_PIXEL, 3, 0, 0, 0, FALSE, TRUE },
+ { "ps_3_sw", NULL, ST_PIXEL, 3, 0, 0, 0, TRUE, FALSE },
+ /* SM 4 */
+ { "vs_4_0_level_9_0", NULL, ST_VERTEX, 4, 0, 9, 0, FALSE, FALSE },
+ { "vs_4_0_level_9_1", NULL, ST_VERTEX, 4, 0, 9, 1, FALSE, FALSE },
+ { "vs_4_0_level_9_3", NULL, ST_VERTEX, 4, 0, 9, 3, FALSE, FALSE },
+ { "vs_4_0", NULL, ST_VERTEX, 4, 0, 0, 0, FALSE, TRUE },
+ { "vs_4_1", NULL, ST_VERTEX, 4, 1, 0, 0, FALSE, TRUE },
+ { "ps_4_0_level_9_0", NULL, ST_PIXEL, 4, 0, 9, 0, FALSE, FALSE },
+ { "ps_4_0_level_9_1", NULL, ST_PIXEL, 4, 0, 9, 1, FALSE, FALSE },
+ { "ps_4_0_level_9_3", NULL, ST_PIXEL, 4, 0, 9, 3, FALSE, FALSE },
+ { "ps_4_0", NULL, ST_PIXEL, 4, 0, 0, 0, FALSE, TRUE },
+ { "ps_4_1", NULL, ST_PIXEL, 4, 1, 0, 0, FALSE, TRUE },
+ { "gs_4_0", NULL, ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
+ { "gs_4_1", NULL, ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
+ { "cs_4_0", NULL, ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
+ { "cs_4_1", NULL, ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
+ { "fx_4_0", NULL, ST_UNKNOWN, 4, 0, 0, 0, FALSE, FALSE },
+ { "fx_4_1", NULL, ST_UNKNOWN, 4, 1, 0, 0, FALSE, FALSE },
+ /* SM 5 */
+ { "vs_5_0", NULL, ST_VERTEX, 5, 0, 0, 0, FALSE, TRUE },
+ { "ps_5_0", NULL, ST_PIXEL, 5, 0, 0, 0, FALSE, TRUE },
+ { "hs_5_0", NULL, ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
+ { "gs_5_0", NULL, ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
+ { "ds_5_0", NULL, ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
+ { "cs_5_0", NULL, ST_UNKNOWN, 5, 0, 0, 0, FALSE, FALSE },
+ { "fx_5_0", NULL, 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 +561,38 @@ 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_targets = 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_targets; i++)
{
- FIXME("Unknown compilation target %s.\n", debugstr_a(target));
- return D3DERR_INVALIDCALL;
+ if (!strcmp(target, targets_info[i].name) ||
+ (targets_info[i].altname && !strcmp(target, targets_info[i].altname)))
+ {
+ 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_targets)
{
- 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..d25b4e5 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -49,8 +49,9 @@ const char *debug_d3dcompiler_shader_variable_type(D3D_SHADER_VARIABLE_TYPE t) D
enum shader_type
{
+ ST_UNKNOWN,
ST_VERTEX,
- ST_PIXEL,
+ ST_PIXEL
};
typedef enum BWRITER_COMPARISON_TYPE {
More information about the wine-patches
mailing list