Commit 8553665c authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Move the shader version to reg_maps.

parent dd094fe6
......@@ -206,7 +206,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
{
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
DWORD shader_version = This->baseShader.hex_version;
DWORD shader_version;
unsigned int cur_loop_depth = 0, max_loop_depth = 0;
const DWORD* pToken = byte_code;
char pshader;
......@@ -236,8 +236,7 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
FIXME("First token is not a version token, invalid shader.\n");
return WINED3DERR_INVALIDCALL;
}
shader_version = *pToken++;
This->baseShader.hex_version = shader_version;
reg_maps->shader_version = shader_version = *pToken++;
pshader = shader_is_pshader_version(shader_version);
while (WINED3DVS_END() != *pToken) {
......@@ -302,7 +301,8 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
memcpy(lconst->value, pToken + 1, 4 * sizeof(DWORD));
/* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
if(WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 && pshader) {
if (WINED3DSHADER_VERSION_MAJOR(shader_version) == 1 && pshader)
{
float *value = (float *) lconst->value;
if(value[0] < -1.0) value[0] = -1.0;
else if(value[0] > 1.0) value[0] = 1.0;
......@@ -361,20 +361,20 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
int i, limit;
/* Declare 1.X samplers implicitly, based on the destination reg. number */
if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 &&
pshader /* Filter different instructions with the same enum values in VS */ &&
(WINED3DSIO_TEX == curOpcode->opcode ||
WINED3DSIO_TEXBEM == curOpcode->opcode ||
WINED3DSIO_TEXBEML == curOpcode->opcode ||
WINED3DSIO_TEXDP3TEX == curOpcode->opcode ||
WINED3DSIO_TEXM3x2TEX == curOpcode->opcode ||
WINED3DSIO_TEXM3x3SPEC == curOpcode->opcode ||
WINED3DSIO_TEXM3x3TEX == curOpcode->opcode ||
WINED3DSIO_TEXM3x3VSPEC == curOpcode->opcode ||
WINED3DSIO_TEXREG2AR == curOpcode->opcode ||
WINED3DSIO_TEXREG2GB == curOpcode->opcode ||
WINED3DSIO_TEXREG2RGB == curOpcode->opcode)) {
if (WINED3DSHADER_VERSION_MAJOR(shader_version) == 1
&& pshader /* Filter different instructions with the same enum values in VS */
&& (WINED3DSIO_TEX == curOpcode->opcode
|| WINED3DSIO_TEXBEM == curOpcode->opcode
|| WINED3DSIO_TEXBEML == curOpcode->opcode
|| WINED3DSIO_TEXDP3TEX == curOpcode->opcode
|| WINED3DSIO_TEXM3x2TEX == curOpcode->opcode
|| WINED3DSIO_TEXM3x3SPEC == curOpcode->opcode
|| WINED3DSIO_TEXM3x3TEX == curOpcode->opcode
|| WINED3DSIO_TEXM3x3VSPEC == curOpcode->opcode
|| WINED3DSIO_TEXREG2AR == curOpcode->opcode
|| WINED3DSIO_TEXREG2GB == curOpcode->opcode
|| WINED3DSIO_TEXREG2RGB == curOpcode->opcode))
{
/* Fake sampler usage, only set reserved bit and ttype */
DWORD sampler_code = *pToken & WINED3DSP_REGNUM_MASK;
......@@ -476,8 +476,9 @@ HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, struct shader_reg_m
* 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
*/
else if(WINED3DSPR_TEXCRDOUT == regtype && i == 0 /* Only look at writes */ &&
!pshader && WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) < 3) {
else if (WINED3DSPR_TEXCRDOUT == regtype && i == 0 /* Only look at writes */
&& !pshader && WINED3DSHADER_VERSION_MAJOR(shader_version) < 3)
{
reg_maps->texcoord_mask[reg] |= shader_get_writemask(param);
}
}
......@@ -832,7 +833,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
const SHADER_OPCODE *opcode_table = This->baseShader.shader_ins;
const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
DWORD shader_version = This->baseShader.hex_version;
DWORD shader_version = reg_maps->shader_version;
const DWORD *pToken = pFunction;
const SHADER_OPCODE *curOpcode = NULL;
SHADER_HANDLER hw_fct = NULL;
......
......@@ -226,7 +226,8 @@ static void pshader_set_limits(
This->baseShader.limits.address = 0;
This->baseShader.limits.packed_output = 0;
switch (This->baseShader.hex_version) {
switch (This->baseShader.reg_maps.shader_version)
{
case WINED3DPS_VERSION(1,0):
case WINED3DPS_VERSION(1,1):
case WINED3DPS_VERSION(1,2):
......@@ -293,8 +294,8 @@ static void pshader_set_limits(
This->baseShader.limits.sampler = 16;
This->baseShader.limits.packed_input = 0;
This->baseShader.limits.label = 0;
FIXME("Unrecognized pixel shader version %#x\n",
This->baseShader.hex_version);
FIXME("Unrecognized pixel shader version %#x\n",
This->baseShader.reg_maps.shader_version);
}
}
......@@ -395,9 +396,9 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
return WINED3D_OK;
}
static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures,
DWORD shader_version)
static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures)
{
DWORD shader_version = reg_maps->shader_version;
DWORD *samplers = reg_maps->samplers;
unsigned int i;
......@@ -448,7 +449,7 @@ static GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, const struct ps
TRACE("(%p) : function %p\n", This, function);
pixelshader_update_samplers(&This->baseShader.reg_maps,
((IWineD3DDeviceImpl *)This->baseShader.device)->stateBlock->textures, This->baseShader.hex_version);
((IWineD3DDeviceImpl *)This->baseShader.device)->stateBlock->textures);
/* Reset fields tracking stateblock values being hardcoded in the shader */
This->baseShader.num_sampled_samplers = 0;
......@@ -493,7 +494,8 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImp
}
args->color_fixup[sampler] = tex->baseTexture.shader_color_fixup;
}
if(shader->baseShader.hex_version >= WINED3DPS_VERSION(3,0)) {
if (shader->baseShader.reg_maps.shader_version >= WINED3DPS_VERSION(3,0))
{
if(((IWineD3DDeviceImpl *) shader->baseShader.device)->strided_streams.u.s.position_transformed) {
args->vp_mode = pretransformed;
} else if(use_vs((IWineD3DDeviceImpl *) shader->baseShader.device)) {
......
......@@ -901,8 +901,9 @@ static void state_stencilwrite(DWORD state, IWineD3DStateBlockImpl *stateblock,
static void state_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
BOOL fogenable = stateblock->renderState[WINED3DRS_FOGENABLE];
IWineD3DPixelShaderImpl *ps_impl = (IWineD3DPixelShaderImpl *)stateblock->pixelShader;
BOOL is_ps3 = use_ps(stateblock->wineD3DDevice)
&& ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.hex_version >= WINED3DPS_VERSION(3,0);
&& ps_impl->baseShader.reg_maps.shader_version >= WINED3DPS_VERSION(3,0);
float fogstart, fogend;
union {
......@@ -914,8 +915,9 @@ static void state_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCo
/* No fog? Disable it, and we're done :-) */
glDisable(GL_FOG);
checkGLcall("glDisable GL_FOG");
if( use_ps(stateblock->wineD3DDevice)
&& ((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.hex_version < WINED3DPS_VERSION(3,0) ) {
if (use_ps(stateblock->wineD3DDevice)
&& ps_impl->baseShader.reg_maps.shader_version < WINED3DPS_VERSION(3,0))
{
/* disable fog in the pixel shader
* NOTE: For pixel shader, GL_FOG_START and GL_FOG_END don't hold fog start s and end e but
* -1/(e-s) and e/(e-s) respectively.
......
......@@ -120,7 +120,8 @@ static void vshader_set_limits(
/* Must match D3DCAPS9.MaxVertexShaderConst: at least 256 for vs_2_0 */
This->baseShader.limits.constant_float = GL_LIMITS(vshader_constantsF);
switch (This->baseShader.hex_version) {
switch (This->baseShader.reg_maps.shader_version)
{
case WINED3DVS_VERSION(1,0):
case WINED3DVS_VERSION(1,1):
This->baseShader.limits.temporary = 12;
......@@ -161,7 +162,7 @@ static void vshader_set_limits(
This->baseShader.limits.sampler = 0;
This->baseShader.limits.label = 16;
FIXME("Unrecognized vertex shader version %#x\n",
This->baseShader.hex_version);
This->baseShader.reg_maps.shader_version);
}
}
......
......@@ -2067,7 +2067,7 @@ typedef struct local_constant {
} local_constant;
typedef struct shader_reg_maps {
DWORD shader_version;
char texcoord[MAX_REG_TEXCRD]; /* pixel < 3.0 */
char temporary[MAX_REG_TEMP]; /* pixel, vertex */
char address[MAX_REG_ADDR]; /* vertex */
......@@ -2185,7 +2185,6 @@ extern void shader_glsl_add_instruction_modifiers(const SHADER_OPCODE_ARG *arg);
typedef struct IWineD3DBaseShaderClass
{
LONG ref;
DWORD hex_version;
SHADER_LIMITS limits;
SHADER_PARSE_STATE parse_state;
CONST SHADER_OPCODE *shader_ins;
......
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