Commit 65622a05 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Create a struct wined3d_shader_version to store version information.

The version tokens in SM1-3 and SM4 are similar, but not the same.
parent 5c63d93e
...@@ -318,7 +318,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 ...@@ -318,7 +318,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
{ {
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
void *fe_data = This->baseShader.frontend_data; void *fe_data = This->baseShader.frontend_data;
DWORD shader_version; struct wined3d_shader_version shader_version;
unsigned int cur_loop_depth = 0, max_loop_depth = 0; unsigned int cur_loop_depth = 0, max_loop_depth = 0;
const DWORD* pToken = byte_code; const DWORD* pToken = byte_code;
char pshader; char pshader;
...@@ -336,7 +336,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 ...@@ -336,7 +336,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
fe->shader_read_header(fe_data, &pToken, &shader_version); fe->shader_read_header(fe_data, &pToken, &shader_version);
reg_maps->shader_version = shader_version; reg_maps->shader_version = shader_version;
pshader = shader_is_pshader_version(shader_version); pshader = shader_is_pshader_version(shader_version.type);
while (!fe->shader_is_end(fe_data, &pToken)) while (!fe->shader_is_end(fe_data, &pToken))
{ {
...@@ -408,7 +408,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 ...@@ -408,7 +408,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
pToken += 4; pToken += 4;
/* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */ /* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
if (WINED3DSHADER_VERSION_MAJOR(shader_version) == 1 && pshader) if (shader_version.major == 1 && pshader)
{ {
float *value = (float *) lconst->value; float *value = (float *) lconst->value;
if(value[0] < -1.0) value[0] = -1.0; if(value[0] < -1.0) value[0] = -1.0;
...@@ -513,8 +513,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 ...@@ -513,8 +513,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
/* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and /* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and
* is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel * is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel
* shaders because TECRDOUT isn't used in them, but future register types might cause issues */ * shaders because TECRDOUT isn't used in them, but future register types might cause issues */
if (!pshader && WINED3DSHADER_VERSION_MAJOR(shader_version) < 3 if (!pshader && shader_version.major < 3 && dst_param.register_type == WINED3DSPR_TEXCRDOUT)
&& dst_param.register_type == WINED3DSPR_TEXCRDOUT)
{ {
reg_maps->texcoord_mask[dst_param.register_type] |= dst_param.write_mask; reg_maps->texcoord_mask[dst_param.register_type] |= dst_param.write_mask;
} }
...@@ -525,7 +524,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 ...@@ -525,7 +524,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
} }
/* Declare 1.X samplers implicitly, based on the destination reg. number */ /* Declare 1.X samplers implicitly, based on the destination reg. number */
if (WINED3DSHADER_VERSION_MAJOR(shader_version) == 1 if (shader_version.major == 1
&& pshader /* Filter different instructions with the same enum values in VS */ && pshader /* Filter different instructions with the same enum values in VS */
&& (ins.handler_idx == WINED3DSIH_TEX && (ins.handler_idx == WINED3DSIH_TEX
|| ins.handler_idx == WINED3DSIH_TEXBEM || ins.handler_idx == WINED3DSIH_TEXBEM
...@@ -593,7 +592,8 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3 ...@@ -593,7 +592,8 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3
return WINED3D_OK; return WINED3D_OK;
} }
static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic, DWORD shader_version) static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic,
const struct wined3d_shader_version *shader_version)
{ {
TRACE("dcl"); TRACE("dcl");
...@@ -610,7 +610,7 @@ static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semanti ...@@ -610,7 +610,7 @@ static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semanti
else else
{ {
/* Pixel shaders 3.0 don't have usage semantics */ /* Pixel shaders 3.0 don't have usage semantics */
if (shader_is_pshader_version(shader_version) && shader_version < WINED3DPS_VERSION(3,0)) if (shader_is_pshader_version(shader_version->type) && shader_version->major < 3)
return; return;
else else
TRACE("_"); TRACE("_");
...@@ -667,7 +667,7 @@ static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semanti ...@@ -667,7 +667,7 @@ static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semanti
} }
static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx, static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx,
const struct wined3d_shader_src_param *rel_addr, DWORD shader_version) const struct wined3d_shader_src_param *rel_addr, const struct wined3d_shader_version *shader_version)
{ {
static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"}; static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
static const char * const misctype_reg_names[] = {"vPos", "vFace"}; static const char * const misctype_reg_names[] = {"vPos", "vFace"};
...@@ -692,7 +692,7 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type ...@@ -692,7 +692,7 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type
break; break;
case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */ case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
TRACE("%c", shader_is_pshader_version(shader_version) ? 't' : 'a'); TRACE("%c", shader_is_pshader_version(shader_version->type) ? 't' : 'a');
break; break;
case WINED3DSPR_RASTOUT: case WINED3DSPR_RASTOUT:
...@@ -714,7 +714,7 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type ...@@ -714,7 +714,7 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type
case WINED3DSPR_TEXCRDOUT: case WINED3DSPR_TEXCRDOUT:
/* Vertex shaders >= 3.0 use general purpose output registers /* Vertex shaders >= 3.0 use general purpose output registers
* (WINED3DSPR_OUTPUT), which can include an address token */ * (WINED3DSPR_OUTPUT), which can include an address token */
if (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 3) TRACE("o"); if (shader_version->major >= 3) TRACE("o");
else TRACE("oT"); else TRACE("oT");
break; break;
...@@ -765,7 +765,8 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type ...@@ -765,7 +765,8 @@ static void shader_dump_register(WINED3DSHADER_PARAM_REGISTER_TYPE register_type
} }
} }
void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, DWORD shader_version) void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
const struct wined3d_shader_version *shader_version)
{ {
DWORD write_mask = param->write_mask; DWORD write_mask = param->write_mask;
...@@ -783,7 +784,8 @@ void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, DWORD s ...@@ -783,7 +784,8 @@ void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, DWORD s
} }
} }
void shader_dump_src_param(const struct wined3d_shader_src_param *param, DWORD shader_version) void shader_dump_src_param(const struct wined3d_shader_src_param *param,
const struct wined3d_shader_version *shader_version)
{ {
DWORD src_modifier = param->modifiers; DWORD src_modifier = param->modifiers;
DWORD swizzle = param->swizzle; DWORD swizzle = param->swizzle;
...@@ -861,13 +863,13 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, ...@@ -861,13 +863,13 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
void *fe_data = This->baseShader.frontend_data; void *fe_data = This->baseShader.frontend_data;
struct wined3d_shader_src_param src_rel_addr[4]; struct wined3d_shader_src_param src_rel_addr[4];
struct wined3d_shader_src_param src_param[4]; struct wined3d_shader_src_param src_param[4];
struct wined3d_shader_version shader_version;
struct wined3d_shader_src_param dst_rel_addr; struct wined3d_shader_src_param dst_rel_addr;
struct wined3d_shader_dst_param dst_param; struct wined3d_shader_dst_param dst_param;
struct wined3d_shader_instruction ins; struct wined3d_shader_instruction ins;
struct wined3d_shader_context ctx; struct wined3d_shader_context ctx;
const DWORD *pToken = pFunction; const DWORD *pToken = pFunction;
SHADER_HANDLER hw_fct; SHADER_HANDLER hw_fct;
DWORD shader_version;
DWORD i; DWORD i;
/* Initialize current parsing state */ /* Initialize current parsing state */
...@@ -975,16 +977,16 @@ static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst ...@@ -975,16 +977,16 @@ static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst
void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction)
{ {
struct wined3d_shader_version shader_version;
const DWORD* pToken = pFunction; const DWORD* pToken = pFunction;
DWORD shader_version;
DWORD i; DWORD i;
TRACE("Parsing %p\n", pFunction); TRACE("Parsing %p\n", pFunction);
fe->shader_read_header(fe_data, &pToken, &shader_version); fe->shader_read_header(fe_data, &pToken, &shader_version);
TRACE("%s_%u_%u\n", shader_is_pshader_version(shader_version) ? "ps": "vs", TRACE("%s_%u_%u\n", shader_is_pshader_version(shader_version.type) ? "ps": "vs",
WINED3DSHADER_VERSION_MAJOR(shader_version), WINED3DSHADER_VERSION_MINOR(shader_version)); shader_version.major, shader_version.minor);
while (!fe->shader_is_end(fe_data, &pToken)) while (!fe->shader_is_end(fe_data, &pToken))
{ {
...@@ -1014,10 +1016,10 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, ...@@ -1014,10 +1016,10 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data,
fe->shader_read_semantic(&pToken, &semantic); fe->shader_read_semantic(&pToken, &semantic);
shader_dump_decl_usage(&semantic, shader_version); shader_dump_decl_usage(&semantic, &shader_version);
shader_dump_ins_modifiers(&semantic.reg); shader_dump_ins_modifiers(&semantic.reg);
TRACE(" "); TRACE(" ");
shader_dump_dst_param(&semantic.reg, shader_version); shader_dump_dst_param(&semantic.reg, &shader_version);
} }
else if (ins.handler_idx == WINED3DSIH_DEF) else if (ins.handler_idx == WINED3DSIH_DEF)
{ {
...@@ -1074,7 +1076,7 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, ...@@ -1074,7 +1076,7 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data,
{ {
fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr); fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
TRACE("("); TRACE("(");
shader_dump_src_param(&src_param, shader_version); shader_dump_src_param(&src_param, &shader_version);
TRACE(") "); TRACE(") ");
} }
...@@ -1098,7 +1100,7 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, ...@@ -1098,7 +1100,7 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data,
} }
} }
else if (ins.handler_idx == WINED3DSIH_TEX else if (ins.handler_idx == WINED3DSIH_TEX
&& shader_version >= WINED3DPS_VERSION(2,0) && shader_version.major >= 2
&& (ins.flags & WINED3DSI_TEXLD_PROJECT)) && (ins.flags & WINED3DSI_TEXLD_PROJECT))
{ {
TRACE("p"); TRACE("p");
...@@ -1109,7 +1111,7 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, ...@@ -1109,7 +1111,7 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data,
{ {
shader_dump_ins_modifiers(&dst_param); shader_dump_ins_modifiers(&dst_param);
TRACE(" "); TRACE(" ");
shader_dump_dst_param(&dst_param, shader_version); shader_dump_dst_param(&dst_param, &shader_version);
} }
/* Other source tokens */ /* Other source tokens */
...@@ -1117,7 +1119,7 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, ...@@ -1117,7 +1119,7 @@ void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data,
{ {
fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr); fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
TRACE(!i ? " " : ", "); TRACE(!i ? " " : ", ");
shader_dump_src_param(&src_param, shader_version); shader_dump_src_param(&src_param, &shader_version);
} }
} }
TRACE("\n"); TRACE("\n");
......
...@@ -122,16 +122,19 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_GetFunction(IWineD3DPixelShader* ...@@ -122,16 +122,19 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_GetFunction(IWineD3DPixelShader*
static void pshader_set_limits(IWineD3DPixelShaderImpl *This) static void pshader_set_limits(IWineD3DPixelShaderImpl *This)
{ {
DWORD shader_version = WINED3D_SHADER_VERSION(This->baseShader.reg_maps.shader_version.major,
This->baseShader.reg_maps.shader_version.minor);
This->baseShader.limits.attributes = 0; This->baseShader.limits.attributes = 0;
This->baseShader.limits.address = 0; This->baseShader.limits.address = 0;
This->baseShader.limits.packed_output = 0; This->baseShader.limits.packed_output = 0;
switch (This->baseShader.reg_maps.shader_version) switch (shader_version)
{ {
case WINED3DPS_VERSION(1,0): case WINED3D_SHADER_VERSION(1,0):
case WINED3DPS_VERSION(1,1): case WINED3D_SHADER_VERSION(1,1):
case WINED3DPS_VERSION(1,2): case WINED3D_SHADER_VERSION(1,2):
case WINED3DPS_VERSION(1,3): case WINED3D_SHADER_VERSION(1,3):
This->baseShader.limits.temporary = 2; This->baseShader.limits.temporary = 2;
This->baseShader.limits.constant_float = 8; This->baseShader.limits.constant_float = 8;
This->baseShader.limits.constant_int = 0; This->baseShader.limits.constant_int = 0;
...@@ -142,7 +145,7 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This) ...@@ -142,7 +145,7 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This)
This->baseShader.limits.label = 0; This->baseShader.limits.label = 0;
break; break;
case WINED3DPS_VERSION(1,4): case WINED3D_SHADER_VERSION(1,4):
This->baseShader.limits.temporary = 6; This->baseShader.limits.temporary = 6;
This->baseShader.limits.constant_float = 8; This->baseShader.limits.constant_float = 8;
This->baseShader.limits.constant_int = 0; This->baseShader.limits.constant_int = 0;
...@@ -154,7 +157,7 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This) ...@@ -154,7 +157,7 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This)
break; break;
/* FIXME: temporaries must match D3DPSHADERCAPS2_0.NumTemps */ /* FIXME: temporaries must match D3DPSHADERCAPS2_0.NumTemps */
case WINED3DPS_VERSION(2,0): case WINED3D_SHADER_VERSION(2,0):
This->baseShader.limits.temporary = 32; This->baseShader.limits.temporary = 32;
This->baseShader.limits.constant_float = 32; This->baseShader.limits.constant_float = 32;
This->baseShader.limits.constant_int = 16; This->baseShader.limits.constant_int = 16;
...@@ -164,7 +167,7 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This) ...@@ -164,7 +167,7 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This)
This->baseShader.limits.packed_input = 0; This->baseShader.limits.packed_input = 0;
break; break;
case WINED3DPS_VERSION(2,1): case WINED3D_SHADER_VERSION(2,1):
This->baseShader.limits.temporary = 32; This->baseShader.limits.temporary = 32;
This->baseShader.limits.constant_float = 32; This->baseShader.limits.constant_float = 32;
This->baseShader.limits.constant_int = 16; This->baseShader.limits.constant_int = 16;
...@@ -175,7 +178,7 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This) ...@@ -175,7 +178,7 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This)
This->baseShader.limits.label = 16; This->baseShader.limits.label = 16;
break; break;
case WINED3DPS_VERSION(3,0): case WINED3D_SHADER_VERSION(3,0):
This->baseShader.limits.temporary = 32; This->baseShader.limits.temporary = 32;
This->baseShader.limits.constant_float = 224; This->baseShader.limits.constant_float = 224;
This->baseShader.limits.constant_int = 16; This->baseShader.limits.constant_int = 16;
...@@ -195,8 +198,9 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This) ...@@ -195,8 +198,9 @@ static void pshader_set_limits(IWineD3DPixelShaderImpl *This)
This->baseShader.limits.sampler = 16; This->baseShader.limits.sampler = 16;
This->baseShader.limits.packed_input = 0; This->baseShader.limits.packed_input = 0;
This->baseShader.limits.label = 0; This->baseShader.limits.label = 0;
FIXME("Unrecognized pixel shader version %#x\n", FIXME("Unrecognized pixel shader version %u.%u\n",
This->baseShader.reg_maps.shader_version); This->baseShader.reg_maps.shader_version.major,
This->baseShader.reg_maps.shader_version.minor);
} }
} }
...@@ -293,11 +297,10 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i ...@@ -293,11 +297,10 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures) static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures)
{ {
DWORD shader_version = reg_maps->shader_version;
WINED3DSAMPLER_TEXTURE_TYPE *sampler_type = reg_maps->sampler_type; WINED3DSAMPLER_TEXTURE_TYPE *sampler_type = reg_maps->sampler_type;
unsigned int i; unsigned int i;
if (WINED3DSHADER_VERSION_MAJOR(shader_version) != 1) return; if (reg_maps->shader_version.major != 1) return;
for (i = 0; i < max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS); ++i) for (i = 0; i < max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS); ++i)
{ {
...@@ -396,7 +399,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImp ...@@ -396,7 +399,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImp
args->np2_fixup |= (1 << i); args->np2_fixup |= (1 << i);
} }
} }
if (shader->baseShader.reg_maps.shader_version >= WINED3DPS_VERSION(3,0)) if (shader->baseShader.reg_maps.shader_version.major >= 3)
{ {
if (((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.position_transformed) if (((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.position_transformed)
{ {
......
...@@ -40,6 +40,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); ...@@ -40,6 +40,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define WINED3D_SM4_SWIZZLE_SHIFT 4 #define WINED3D_SM4_SWIZZLE_SHIFT 4
#define WINED3D_SM4_SWIZZLE_MASK (0xff << WINED3D_SM4_SWIZZLE_SHIFT) #define WINED3D_SM4_SWIZZLE_MASK (0xff << WINED3D_SM4_SWIZZLE_SHIFT)
#define WINED3D_SM4_VERSION_MAJOR(version) (((version) >> 4) & 0xf)
#define WINED3D_SM4_VERSION_MINOR(version) (((version) >> 0) & 0xf)
enum wined3d_sm4_opcode enum wined3d_sm4_opcode
{ {
WINED3D_SM4_OP_ADD = 0x00, WINED3D_SM4_OP_ADD = 0x00,
...@@ -66,7 +69,7 @@ enum wined3d_sm4_immconst_type ...@@ -66,7 +69,7 @@ enum wined3d_sm4_immconst_type
struct wined3d_sm4_data struct wined3d_sm4_data
{ {
DWORD shader_version; struct wined3d_shader_version shader_version;
const DWORD *end; const DWORD *end;
}; };
...@@ -126,17 +129,40 @@ static void shader_sm4_free(void *data) ...@@ -126,17 +129,40 @@ static void shader_sm4_free(void *data)
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
} }
static void shader_sm4_read_header(void *data, const DWORD **ptr, DWORD *shader_version) static void shader_sm4_read_header(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version)
{ {
struct wined3d_sm4_data *priv = data; struct wined3d_sm4_data *priv = data;
DWORD version_token;
priv->end = *ptr; priv->end = *ptr;
TRACE("version: 0x%08x\n", **ptr); version_token = *(*ptr)++;
*shader_version = *(*ptr)++; TRACE("version: 0x%08x\n", version_token);
TRACE("token count: %u\n", **ptr); TRACE("token count: %u\n", **ptr);
priv->end += *(*ptr)++; priv->end += *(*ptr)++;
priv->shader_version = *shader_version; switch (version_token >> 16)
{
case WINED3D_SM4_PS:
priv->shader_version.type = WINED3D_SHADER_TYPE_PIXEL;
break;
case WINED3D_SM4_VS:
priv->shader_version.type = WINED3D_SHADER_TYPE_VERTEX;
break;
case WINED3D_SM4_GS:
priv->shader_version.type = WINED3D_SHADER_TYPE_GEOMETRY;
break;
default:
FIXME("Unrecognized shader type %#x\n", version_token >> 16);
}
priv->shader_version.major = WINED3D_SM4_VERSION_MAJOR(version_token);
priv->shader_version.minor = WINED3D_SM4_VERSION_MINOR(version_token);
*shader_version = priv->shader_version;
} }
static void shader_sm4_read_opcode(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins, static void shader_sm4_read_opcode(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins,
......
...@@ -36,14 +36,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); ...@@ -36,14 +36,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
static void vshader_set_limits(IWineD3DVertexShaderImpl *This) static void vshader_set_limits(IWineD3DVertexShaderImpl *This)
{ {
DWORD shader_version = WINED3D_SHADER_VERSION(This->baseShader.reg_maps.shader_version.major,
This->baseShader.reg_maps.shader_version.minor);
This->baseShader.limits.texcoord = 0; This->baseShader.limits.texcoord = 0;
This->baseShader.limits.attributes = 16; This->baseShader.limits.attributes = 16;
This->baseShader.limits.packed_input = 0; This->baseShader.limits.packed_input = 0;
switch (This->baseShader.reg_maps.shader_version) switch (shader_version)
{ {
case WINED3DVS_VERSION(1,0): case WINED3D_SHADER_VERSION(1,0):
case WINED3DVS_VERSION(1,1): case WINED3D_SHADER_VERSION(1,1):
This->baseShader.limits.temporary = 12; This->baseShader.limits.temporary = 12;
This->baseShader.limits.constant_bool = 0; This->baseShader.limits.constant_bool = 0;
This->baseShader.limits.constant_int = 0; This->baseShader.limits.constant_int = 0;
...@@ -56,8 +59,8 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) ...@@ -56,8 +59,8 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This)
This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF));
break; break;
case WINED3DVS_VERSION(2,0): case WINED3D_SHADER_VERSION(2,0):
case WINED3DVS_VERSION(2,1): case WINED3D_SHADER_VERSION(2,1):
This->baseShader.limits.temporary = 12; This->baseShader.limits.temporary = 12;
This->baseShader.limits.constant_bool = 16; This->baseShader.limits.constant_bool = 16;
This->baseShader.limits.constant_int = 16; This->baseShader.limits.constant_int = 16;
...@@ -68,7 +71,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) ...@@ -68,7 +71,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This)
This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF));
break; break;
case WINED3DVS_VERSION(3,0): case WINED3D_SHADER_VERSION(3,0):
This->baseShader.limits.temporary = 32; This->baseShader.limits.temporary = 32;
This->baseShader.limits.constant_bool = 32; This->baseShader.limits.constant_bool = 32;
This->baseShader.limits.constant_int = 32; This->baseShader.limits.constant_int = 32;
...@@ -92,8 +95,9 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) ...@@ -92,8 +95,9 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This)
This->baseShader.limits.sampler = 0; This->baseShader.limits.sampler = 0;
This->baseShader.limits.label = 16; This->baseShader.limits.label = 16;
This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF));
FIXME("Unrecognized vertex shader version %#x\n", FIXME("Unrecognized vertex shader version %u.%u\n",
This->baseShader.reg_maps.shader_version); This->baseShader.reg_maps.shader_version.major,
This->baseShader.reg_maps.shader_version.minor);
} }
} }
......
...@@ -486,8 +486,6 @@ typedef enum COMPARISON_TYPE ...@@ -486,8 +486,6 @@ typedef enum COMPARISON_TYPE
/* Shader version tokens, and shader end tokens */ /* Shader version tokens, and shader end tokens */
#define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor)) #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
#define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor)) #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
#define WINED3DSHADER_VERSION_MAJOR(version) (((version) >> 8) & 0xff)
#define WINED3DSHADER_VERSION_MINOR(version) (((version) >> 0) & 0xff)
/* Shader backends */ /* Shader backends */
...@@ -601,9 +599,25 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER ...@@ -601,9 +599,25 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_TABLE_SIZE WINED3DSIH_TABLE_SIZE
}; };
enum wined3d_shader_type
{
WINED3D_SHADER_TYPE_PIXEL,
WINED3D_SHADER_TYPE_VERTEX,
WINED3D_SHADER_TYPE_GEOMETRY,
};
struct wined3d_shader_version
{
enum wined3d_shader_type type;
BYTE major;
BYTE minor;
};
#define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
typedef struct shader_reg_maps typedef struct shader_reg_maps
{ {
DWORD shader_version; struct wined3d_shader_version shader_version;
char texcoord[MAX_REG_TEXCRD]; /* pixel < 3.0 */ char texcoord[MAX_REG_TEXCRD]; /* pixel < 3.0 */
char temporary[MAX_REG_TEMP]; /* pixel, vertex */ char temporary[MAX_REG_TEMP]; /* pixel, vertex */
char address[MAX_REG_ADDR]; /* vertex */ char address[MAX_REG_ADDR]; /* vertex */
...@@ -681,7 +695,7 @@ struct wined3d_shader_frontend ...@@ -681,7 +695,7 @@ struct wined3d_shader_frontend
{ {
void *(*shader_init)(const DWORD *ptr); void *(*shader_init)(const DWORD *ptr);
void (*shader_free)(void *data); void (*shader_free)(void *data);
void (*shader_read_header)(void *data, const DWORD **ptr, DWORD *shader_version); void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
void (*shader_read_opcode)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins, UINT *param_size); void (*shader_read_opcode)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins, UINT *param_size);
void (*shader_read_src_param)(void *data, const DWORD **ptr, struct wined3d_shader_src_param *src_param, void (*shader_read_src_param)(void *data, const DWORD **ptr, struct wined3d_shader_src_param *src_param,
struct wined3d_shader_src_param *src_rel_addr); struct wined3d_shader_src_param *src_rel_addr);
...@@ -2554,8 +2568,10 @@ typedef struct IWineD3DBaseShaderImpl { ...@@ -2554,8 +2568,10 @@ typedef struct IWineD3DBaseShaderImpl {
void shader_buffer_init(struct SHADER_BUFFER *buffer); void shader_buffer_init(struct SHADER_BUFFER *buffer);
void shader_buffer_free(struct SHADER_BUFFER *buffer); void shader_buffer_free(struct SHADER_BUFFER *buffer);
void shader_cleanup(IWineD3DBaseShader *iface); void shader_cleanup(IWineD3DBaseShader *iface);
void shader_dump_src_param(const struct wined3d_shader_src_param *param, DWORD shader_version); void shader_dump_src_param(const struct wined3d_shader_src_param *param,
void shader_dump_dst_param(const struct wined3d_shader_dst_param *param, DWORD shader_version); const struct wined3d_shader_version *shader_version);
void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
const struct wined3d_shader_version *shader_version);
void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer, void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
const shader_reg_maps *reg_maps, const DWORD *pFunction); const shader_reg_maps *reg_maps, const DWORD *pFunction);
HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe, HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
...@@ -2565,12 +2581,14 @@ void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDevice *device) ...@@ -2565,12 +2581,14 @@ void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDevice *device)
const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token); const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token);
void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction); void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction);
static inline BOOL shader_is_pshader_version(DWORD token) { static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type)
return 0xFFFF0000 == (token & 0xFFFF0000); {
return type == WINED3D_SHADER_TYPE_PIXEL;
} }
static inline BOOL shader_is_vshader_version(DWORD token) { static inline BOOL shader_is_vshader_version(enum wined3d_shader_type type)
return 0xFFFE0000 == (token & 0xFFFF0000); {
return type == WINED3D_SHADER_TYPE_VERTEX;
} }
static inline BOOL shader_is_scalar(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx) static inline BOOL shader_is_scalar(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment