Commit ce2e980d authored by Ivan Gyurdiev's avatar Ivan Gyurdiev Committed by Alexandre Julliard

wined3d: Add shader version/end masks to the WINED3D namespace.

parent 98466024
...@@ -638,14 +638,14 @@ void pshader_hw_tex(SHADER_OPCODE_ARG* arg) { ...@@ -638,14 +638,14 @@ void pshader_hw_tex(SHADER_OPCODE_ARG* arg) {
/* 1.0-1.3: Use destination register as coordinate source. /* 1.0-1.3: Use destination register as coordinate source.
1.4+: Use provided coordinate source register. */ 1.4+: Use provided coordinate source register. */
if (hex_version < D3DPS_VERSION(1,4)) if (hex_version < WINED3DPS_VERSION(1,4))
strcpy(reg_coord, reg_dest); strcpy(reg_coord, reg_dest);
else else
pshader_gen_input_modifier_line(buffer, src[0], 0, reg_coord); pshader_gen_input_modifier_line(buffer, src[0], 0, reg_coord);
/* 1.0-1.4: Use destination register number as texture code. /* 1.0-1.4: Use destination register number as texture code.
2.0+: Use provided sampler number as texure code. */ 2.0+: Use provided sampler number as texure code. */
if (hex_version < D3DPS_VERSION(2,0)) if (hex_version < WINED3DPS_VERSION(2,0))
reg_sampler_code = reg_dest_code; reg_sampler_code = reg_dest_code;
else else
reg_sampler_code = src[1] & WINED3DSP_REGNUM_MASK; reg_sampler_code = src[1] & WINED3DSP_REGNUM_MASK;
...@@ -692,7 +692,7 @@ void pshader_hw_texcoord(SHADER_OPCODE_ARG* arg) { ...@@ -692,7 +692,7 @@ void pshader_hw_texcoord(SHADER_OPCODE_ARG* arg) {
char tmp[20]; char tmp[20];
pshader_get_write_mask(dst, tmp); pshader_get_write_mask(dst, tmp);
if (hex_version != D3DPS_VERSION(1,4)) { if (hex_version != WINED3DPS_VERSION(1,4)) {
DWORD reg = dst & WINED3DSP_REGNUM_MASK; DWORD reg = dst & WINED3DSP_REGNUM_MASK;
shader_addline(buffer, "MOV_SAT T%u%s, fragment.texcoord[%u];\n", reg, tmp, reg); shader_addline(buffer, "MOV_SAT T%u%s, fragment.texcoord[%u];\n", reg, tmp, reg);
} else { } else {
......
...@@ -101,7 +101,7 @@ int shader_get_param( ...@@ -101,7 +101,7 @@ int shader_get_param(
* The version check below should work in general */ * The version check below should work in general */
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface; IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
char rel_token = D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2 && char rel_token = WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2 &&
((*pToken & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE); ((*pToken & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE);
*param = *pToken; *param = *pToken;
...@@ -118,7 +118,7 @@ static inline int shader_skip_opcode( ...@@ -118,7 +118,7 @@ static inline int shader_skip_opcode(
/* Shaders >= 2.0 may contain address tokens, but fortunately they /* Shaders >= 2.0 may contain address tokens, but fortunately they
* have a useful legnth mask - use it here. Shaders 1.0 contain no such tokens */ * have a useful legnth mask - use it here. Shaders 1.0 contain no such tokens */
return (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2)? return (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2)?
((opcode_token & WINED3DSI_INSTLENGTH_MASK) >> WINED3DSI_INSTLENGTH_SHIFT): ((opcode_token & WINED3DSI_INSTLENGTH_MASK) >> WINED3DSI_INSTLENGTH_SHIFT):
curOpcode->num_params; curOpcode->num_params;
} }
...@@ -191,7 +191,7 @@ HRESULT shader_get_registers_used( ...@@ -191,7 +191,7 @@ HRESULT shader_get_registers_used(
if (pToken == NULL) if (pToken == NULL)
return WINED3D_OK; return WINED3D_OK;
while (D3DVS_END() != *pToken) { while (WINED3DVS_END() != *pToken) {
CONST SHADER_OPCODE* curOpcode; CONST SHADER_OPCODE* curOpcode;
DWORD opcode_token; DWORD opcode_token;
...@@ -292,7 +292,7 @@ HRESULT shader_get_registers_used( ...@@ -292,7 +292,7 @@ HRESULT shader_get_registers_used(
int i, limit; int i, limit;
/* Declare 1.X samplers implicitly, based on the destination reg. number */ /* Declare 1.X samplers implicitly, based on the destination reg. number */
if (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 && if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 &&
(WINED3DSIO_TEX == curOpcode->opcode || (WINED3DSIO_TEX == curOpcode->opcode ||
WINED3DSIO_TEXBEM == curOpcode->opcode || WINED3DSIO_TEXBEM == curOpcode->opcode ||
WINED3DSIO_TEXM3x2TEX == curOpcode->opcode || WINED3DSIO_TEXM3x2TEX == curOpcode->opcode ||
...@@ -329,7 +329,7 @@ HRESULT shader_get_registers_used( ...@@ -329,7 +329,7 @@ HRESULT shader_get_registers_used(
} }
} }
} else if (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 && } else if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 &&
(WINED3DSIO_TEXM3x3SPEC == curOpcode->opcode || (WINED3DSIO_TEXM3x3SPEC == curOpcode->opcode ||
WINED3DSIO_TEXM3x3VSPEC == curOpcode->opcode)) { WINED3DSIO_TEXM3x3VSPEC == curOpcode->opcode)) {
...@@ -339,7 +339,7 @@ HRESULT shader_get_registers_used( ...@@ -339,7 +339,7 @@ HRESULT shader_get_registers_used(
* For now, use Cube textures because they are more common. */ * For now, use Cube textures because they are more common. */
DWORD sampler_code = *pToken & WINED3DSP_REGNUM_MASK; DWORD sampler_code = *pToken & WINED3DSP_REGNUM_MASK;
reg_maps->samplers[sampler_code] = (0x1 << 31) | WINED3DSTT_CUBE; reg_maps->samplers[sampler_code] = (0x1 << 31) | WINED3DSTT_CUBE;
} else if (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 && } else if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1 &&
(WINED3DSIO_TEXDP3TEX == curOpcode->opcode)) { (WINED3DSIO_TEXDP3TEX == curOpcode->opcode)) {
/* 1D Sampler usage */ /* 1D Sampler usage */
...@@ -414,7 +414,7 @@ static void shader_dump_decl_usage( ...@@ -414,7 +414,7 @@ static void shader_dump_decl_usage(
/* Pixel shaders 3.0 don't have usage semantics */ /* Pixel shaders 3.0 don't have usage semantics */
char pshader = shader_is_pshader_version(This->baseShader.hex_version); char pshader = shader_is_pshader_version(This->baseShader.hex_version);
if (pshader && This->baseShader.hex_version < D3DPS_VERSION(3,0)) if (pshader && This->baseShader.hex_version < WINED3DPS_VERSION(3,0))
return; return;
else else
TRACE("_"); TRACE("_");
...@@ -571,7 +571,7 @@ void shader_dump_param( ...@@ -571,7 +571,7 @@ void shader_dump_param(
/* 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 (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 3) { if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 3) {
TRACE("o"); TRACE("o");
shader_dump_arr_entry(iface, param, addr_token, reg, input); shader_dump_arr_entry(iface, param, addr_token, reg, input);
} }
...@@ -689,7 +689,7 @@ void shader_generate_main( ...@@ -689,7 +689,7 @@ void shader_generate_main(
/* Second pass, process opcodes */ /* Second pass, process opcodes */
if (NULL != pToken) { if (NULL != pToken) {
while (D3DPS_END() != *pToken) { while (WINED3DPS_END() != *pToken) {
/* Skip version token */ /* Skip version token */
if (shader_is_version_token(*pToken)) { if (shader_is_version_token(*pToken)) {
...@@ -821,12 +821,12 @@ void shader_trace_init( ...@@ -821,12 +821,12 @@ void shader_trace_init(
TRACE("(%p) : Parsing programme\n", This); TRACE("(%p) : Parsing programme\n", This);
if (NULL != pToken) { if (NULL != pToken) {
while (D3DVS_END() != *pToken) { while (WINED3DVS_END() != *pToken) {
if (shader_is_version_token(*pToken)) { /** version */ if (shader_is_version_token(*pToken)) { /** version */
This->baseShader.hex_version = *pToken; This->baseShader.hex_version = *pToken;
TRACE("%s_%u_%u\n", shader_is_pshader_version(This->baseShader.hex_version)? "ps": "vs", TRACE("%s_%u_%u\n", shader_is_pshader_version(This->baseShader.hex_version)? "ps": "vs",
D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version), WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version),
D3DSHADER_VERSION_MINOR(This->baseShader.hex_version)); WINED3DSHADER_VERSION_MINOR(This->baseShader.hex_version));
++pToken; ++pToken;
++len; ++len;
continue; continue;
......
...@@ -2206,15 +2206,15 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, ...@@ -2206,15 +2206,15 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
vs_nv_version which is based on NV_vertex_program. For Ati cards there's no easy way, so for vs_nv_version which is based on NV_vertex_program. For Ati cards there's no easy way, so for
now only support 2.0/3.0 detection on Nvidia GeforceFX cards and default to 3.0 for everything else */ now only support 2.0/3.0 detection on Nvidia GeforceFX cards and default to 3.0 for everything else */
if(This->gl_info.vs_nv_version == VS_VERSION_20) if(This->gl_info.vs_nv_version == VS_VERSION_20)
*pCaps->VertexShaderVersion = D3DVS_VERSION(2,0); *pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
else else
*pCaps->VertexShaderVersion = D3DVS_VERSION(3,0); *pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
TRACE_(d3d_caps)("Hardware vertex shader version 3.0 enabled (GLSL)\n"); TRACE_(d3d_caps)("Hardware vertex shader version 3.0 enabled (GLSL)\n");
} else if (vs_selected_mode == SHADER_ARB) { } else if (vs_selected_mode == SHADER_ARB) {
*pCaps->VertexShaderVersion = D3DVS_VERSION(1,1); *pCaps->VertexShaderVersion = WINED3DVS_VERSION(1,1);
TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n"); TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n");
} else if (vs_selected_mode == SHADER_SW) { } else if (vs_selected_mode == SHADER_SW) {
*pCaps->VertexShaderVersion = D3DVS_VERSION(3,0); *pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
TRACE_(d3d_caps)("Software vertex shader version 3.0 enabled\n"); TRACE_(d3d_caps)("Software vertex shader version 3.0 enabled\n");
} else { } else {
*pCaps->VertexShaderVersion = 0; *pCaps->VertexShaderVersion = 0;
...@@ -2227,19 +2227,19 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, ...@@ -2227,19 +2227,19 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
/* See the comment about VS2.0/VS3.0 detection as we do the same here but then based on NV_fragment_program /* See the comment about VS2.0/VS3.0 detection as we do the same here but then based on NV_fragment_program
in case of GeforceFX cards. */ in case of GeforceFX cards. */
if(This->gl_info.ps_nv_version == PS_VERSION_20) if(This->gl_info.ps_nv_version == PS_VERSION_20)
*pCaps->PixelShaderVersion = D3DPS_VERSION(2,0); *pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
else else
*pCaps->PixelShaderVersion = D3DPS_VERSION(3,0); *pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
/* FIXME: The following line is card dependent. -1.0 to 1.0 is a safe default clamp range for now */ /* FIXME: The following line is card dependent. -1.0 to 1.0 is a safe default clamp range for now */
*pCaps->PixelShader1xMaxValue = 1.0; *pCaps->PixelShader1xMaxValue = 1.0;
TRACE_(d3d_caps)("Hardware pixel shader version 3.0 enabled (GLSL)\n"); TRACE_(d3d_caps)("Hardware pixel shader version 3.0 enabled (GLSL)\n");
} else if (ps_selected_mode == SHADER_ARB) { } else if (ps_selected_mode == SHADER_ARB) {
*pCaps->PixelShaderVersion = D3DPS_VERSION(1,4); *pCaps->PixelShaderVersion = WINED3DPS_VERSION(1,4);
*pCaps->PixelShader1xMaxValue = 1.0; *pCaps->PixelShader1xMaxValue = 1.0;
TRACE_(d3d_caps)("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n"); TRACE_(d3d_caps)("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n");
/* FIXME: Uncomment this when there is support for software Pixel Shader 3.0 and PS_SW is defined /* FIXME: Uncomment this when there is support for software Pixel Shader 3.0 and PS_SW is defined
} else if (ps_selected_mode = SHADER_SW) { } else if (ps_selected_mode = SHADER_SW) {
*pCaps->PixelShaderVersion = D3DPS_VERSION(3,0); *pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
*pCaps->PixelShader1xMaxValue = 1.0; *pCaps->PixelShader1xMaxValue = 1.0;
TRACE_(d3d_caps)("Software pixel shader version 3.0 enabled\n"); */ TRACE_(d3d_caps)("Software pixel shader version 3.0 enabled\n"); */
} else { } else {
...@@ -2260,7 +2260,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, ...@@ -2260,7 +2260,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
*pCaps->AdapterOrdinalInGroup = 0; *pCaps->AdapterOrdinalInGroup = 0;
*pCaps->NumberOfAdaptersInGroup = 1; *pCaps->NumberOfAdaptersInGroup = 1;
if(*pCaps->VertexShaderVersion >= D3DVS_VERSION(2,0)) { if(*pCaps->VertexShaderVersion >= WINED3DVS_VERSION(2,0)) {
/* OpenGL supports all formats below, perhaps not always without conversion but it supports them. /* OpenGL supports all formats below, perhaps not always without conversion but it supports them.
Further GLSL doesn't seem to have an official unsigned type as I'm not sure how we handle it Further GLSL doesn't seem to have an official unsigned type as I'm not sure how we handle it
don't advertise it yet. We might need to add some clamping in the shader engine to support it. don't advertise it yet. We might need to add some clamping in the shader engine to support it.
...@@ -2285,7 +2285,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, ...@@ -2285,7 +2285,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
*pCaps->StretchRectFilterCaps = 0; *pCaps->StretchRectFilterCaps = 0;
*pCaps->VertexTextureFilterCaps = 0; *pCaps->VertexTextureFilterCaps = 0;
if(*pCaps->VertexShaderVersion == D3DVS_VERSION(3,0)) { if(*pCaps->VertexShaderVersion == WINED3DVS_VERSION(3,0)) {
/* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering) /* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering)
use the VS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum VS3.0 value. */ use the VS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum VS3.0 value. */
*pCaps->VS20Caps.Caps = D3DVS20CAPS_PREDICATION; *pCaps->VS20Caps.Caps = D3DVS20CAPS_PREDICATION;
...@@ -2295,7 +2295,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, ...@@ -2295,7 +2295,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
*pCaps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */ *pCaps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
*pCaps->MaxVertexShader30InstructionSlots = max(512, This->gl_info.vs_arb_max_instructions); *pCaps->MaxVertexShader30InstructionSlots = max(512, This->gl_info.vs_arb_max_instructions);
} else if(*pCaps->VertexShaderVersion == D3DVS_VERSION(2,0)) { } else if(*pCaps->VertexShaderVersion == WINED3DVS_VERSION(2,0)) {
*pCaps->VS20Caps.Caps = 0; *pCaps->VS20Caps.Caps = 0;
*pCaps->VS20Caps.DynamicFlowControlDepth = D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH; *pCaps->VS20Caps.DynamicFlowControlDepth = D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
*pCaps->VS20Caps.NumTemps = max(12, This->gl_info.vs_arb_max_temps); *pCaps->VS20Caps.NumTemps = max(12, This->gl_info.vs_arb_max_temps);
...@@ -2313,7 +2313,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, ...@@ -2313,7 +2313,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
*pCaps->MaxVertexShader30InstructionSlots = 0; *pCaps->MaxVertexShader30InstructionSlots = 0;
} }
if(*pCaps->PixelShaderVersion == D3DPS_VERSION(3,0)) { if(*pCaps->PixelShaderVersion == WINED3DPS_VERSION(3,0)) {
/* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering) /* Where possible set the caps based on OpenGL extensions and if they aren't set (in case of software rendering)
use the PS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum PS 3.0 value. */ use the PS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum PS 3.0 value. */
...@@ -2330,7 +2330,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, ...@@ -2330,7 +2330,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
*pCaps->MaxPShaderInstructionsExecuted = 65535; *pCaps->MaxPShaderInstructionsExecuted = 65535;
*pCaps->MaxPixelShader30InstructionSlots = max(D3DMIN30SHADERINSTRUCTIONS, This->gl_info.ps_arb_max_instructions); *pCaps->MaxPixelShader30InstructionSlots = max(D3DMIN30SHADERINSTRUCTIONS, This->gl_info.ps_arb_max_instructions);
} else if(*pCaps->PixelShaderVersion == D3DPS_VERSION(2,0)) { } else if(*pCaps->PixelShaderVersion == WINED3DPS_VERSION(2,0)) {
/* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */ /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
*pCaps->PS20Caps.Caps = 0; *pCaps->PS20Caps.Caps = 0;
*pCaps->PS20Caps.DynamicFlowControlDepth = 0; /* D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */ *pCaps->PS20Caps.DynamicFlowControlDepth = 0; /* D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
......
...@@ -616,7 +616,7 @@ static void shader_glsl_get_register_name( ...@@ -616,7 +616,7 @@ static void shader_glsl_get_register_name(
case WINED3DSPR_INPUT: case WINED3DSPR_INPUT:
if (pshader) { if (pshader) {
/* Pixel shaders >= 3.0 */ /* Pixel shaders >= 3.0 */
if (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 3) if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 3)
sprintf(tmpStr, "IN%u", reg); sprintf(tmpStr, "IN%u", reg);
else { else {
if (reg==0) if (reg==0)
...@@ -639,7 +639,7 @@ static void shader_glsl_get_register_name( ...@@ -639,7 +639,7 @@ static void shader_glsl_get_register_name(
/* Relative addressing on shaders 2.0+ have a relative address token, /* Relative addressing on shaders 2.0+ have a relative address token,
* prior to that, it was hard-coded as "A0.x" because there's only 1 register */ * prior to that, it was hard-coded as "A0.x" because there's only 1 register */
if (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2) { if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2) {
char relStr[100], relReg[50], relMask[6]; char relStr[100], relReg[50], relMask[6];
shader_glsl_add_param(arg, addr_token, 0, TRUE, relReg, relMask, relStr); shader_glsl_add_param(arg, addr_token, 0, TRUE, relReg, relMask, relStr);
sprintf(tmpStr, "%s[%s + %u]", prefix, relStr, reg); sprintf(tmpStr, "%s[%s + %u]", prefix, relStr, reg);
...@@ -708,7 +708,7 @@ static void shader_glsl_get_register_name( ...@@ -708,7 +708,7 @@ static void shader_glsl_get_register_name(
break; break;
case WINED3DSPR_TEXCRDOUT: case WINED3DSPR_TEXCRDOUT:
/* Vertex shaders >= 3.0: WINED3DSPR_OUTPUT */ /* Vertex shaders >= 3.0: WINED3DSPR_OUTPUT */
if (D3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 3) if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 3)
sprintf(tmpStr, "OUT%u", reg); sprintf(tmpStr, "OUT%u", reg);
else else
sprintf(tmpStr, "gl_TexCoord[%u]", reg); sprintf(tmpStr, "gl_TexCoord[%u]", reg);
...@@ -1010,7 +1010,7 @@ void shader_glsl_expp(SHADER_OPCODE_ARG* arg) { ...@@ -1010,7 +1010,7 @@ void shader_glsl_expp(SHADER_OPCODE_ARG* arg) {
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src_reg, src_mask, src_str); shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src_reg, src_mask, src_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine); shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
if (hex_version < D3DPS_VERSION(2,0)) { if (hex_version < WINED3DPS_VERSION(2,0)) {
shader_addline(arg->buffer, "tmp0.x = vec4(exp2(floor(%s))).x;\n", src_str); shader_addline(arg->buffer, "tmp0.x = vec4(exp2(floor(%s))).x;\n", src_str);
shader_addline(arg->buffer, "tmp0.y = vec4(%s - floor(%s)).y;\n", src_str, src_str); shader_addline(arg->buffer, "tmp0.y = vec4(%s - floor(%s)).y;\n", src_str, src_str);
shader_addline(arg->buffer, "tmp0.z = vec4(exp2(%s)).x;\n", src_str); shader_addline(arg->buffer, "tmp0.z = vec4(exp2(%s)).x;\n", src_str);
...@@ -1376,14 +1376,14 @@ void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) { ...@@ -1376,14 +1376,14 @@ void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) {
/* 1.0-1.3: Use destination register as coordinate source. /* 1.0-1.3: Use destination register as coordinate source.
1.4+: Use provided coordinate source register. */ 1.4+: Use provided coordinate source register. */
if (hex_version < D3DPS_VERSION(1,4)) if (hex_version < WINED3DPS_VERSION(1,4))
strcpy(coord_reg, dst_reg); strcpy(coord_reg, dst_reg);
else else
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, coord_reg, coord_mask, coord_str); shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, coord_reg, coord_mask, coord_str);
/* 1.0-1.4: Use destination register as coordinate source. /* 1.0-1.4: Use destination register as coordinate source.
* 2.0+: Use provided coordinate source register. */ * 2.0+: Use provided coordinate source register. */
if (hex_version < D3DPS_VERSION(2,0)) { if (hex_version < WINED3DPS_VERSION(2,0)) {
sprintf(sampler_str, "Psampler%u", reg_dest_code); sprintf(sampler_str, "Psampler%u", reg_dest_code);
sampler_code = reg_dest_code; sampler_code = reg_dest_code;
} }
...@@ -1445,7 +1445,7 @@ void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg) { ...@@ -1445,7 +1445,7 @@ void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg) {
shader_glsl_add_param(arg, arg->dst, 0, FALSE, tmpReg, tmpMask, tmpStr); shader_glsl_add_param(arg, arg->dst, 0, FALSE, tmpReg, tmpMask, tmpStr);
if (hex_version != D3DPS_VERSION(1,4)) { if (hex_version != WINED3DPS_VERSION(1,4)) {
DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK; DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
shader_addline(buffer, "%s = clamp(gl_TexCoord[%u], 0.0, 1.0);\n", tmpReg, reg); shader_addline(buffer, "%s = clamp(gl_TexCoord[%u], 0.0, 1.0);\n", tmpReg, reg);
} else { } else {
......
...@@ -515,8 +515,8 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = { ...@@ -515,8 +515,8 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = {
*/ */
{WINED3DSIO_NRM, "nrm", NULL, 1, 2, vshader_nrm, NULL, shader_glsl_map2gl, 0, 0}, {WINED3DSIO_NRM, "nrm", NULL, 1, 2, vshader_nrm, NULL, shader_glsl_map2gl, 0, 0},
{WINED3DSIO_SINCOS, "sincos", NULL, 1, 4, vshader_sincos2, NULL, shader_glsl_sincos, D3DVS_VERSION(2,0), D3DVS_VERSION(2,0)}, {WINED3DSIO_SINCOS, "sincos", NULL, 1, 4, vshader_sincos2, NULL, shader_glsl_sincos, WINED3DVS_VERSION(2,0), WINED3DVS_VERSION(2,0)},
{WINED3DSIO_SINCOS, "sincos", NULL, 1, 2, vshader_sincos3, NULL, shader_glsl_sincos, D3DVS_VERSION(3,0), -1}, {WINED3DSIO_SINCOS, "sincos", NULL, 1, 2, vshader_sincos3, NULL, shader_glsl_sincos, WINED3DVS_VERSION(3,0), -1},
/* Matrix */ /* Matrix */
{WINED3DSIO_M4x4, "m4x4", "undefined", 1, 3, vshader_m4x4, vshader_hw_mnxn, shader_glsl_mnxn, 0, 0}, {WINED3DSIO_M4x4, "m4x4", "undefined", 1, 3, vshader_m4x4, vshader_hw_mnxn, shader_glsl_mnxn, 0, 0},
...@@ -534,21 +534,21 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = { ...@@ -534,21 +534,21 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = {
{WINED3DSIO_DEFI, "defi", GLNAME_REQUIRE_GLSL, 1, 5, vshader_defi, NULL, NULL, 0, 0}, {WINED3DSIO_DEFI, "defi", GLNAME_REQUIRE_GLSL, 1, 5, vshader_defi, NULL, NULL, 0, 0},
/* Flow control - requires GLSL or software shaders */ /* Flow control - requires GLSL or software shaders */
{WINED3DSIO_REP , "rep", NULL, 0, 1, vshader_rep, NULL, shader_glsl_rep, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_REP , "rep", NULL, 0, 1, vshader_rep, NULL, shader_glsl_rep, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_ENDREP, "endrep", NULL, 0, 0, vshader_endrep, NULL, shader_glsl_end, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_ENDREP, "endrep", NULL, 0, 0, vshader_endrep, NULL, shader_glsl_end, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_IF, "if", NULL, 0, 1, vshader_if, NULL, shader_glsl_if, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_IF, "if", NULL, 0, 1, vshader_if, NULL, shader_glsl_if, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_IFC, "ifc", NULL, 0, 2, vshader_ifc, NULL, shader_glsl_ifc, D3DVS_VERSION(2,1), -1}, {WINED3DSIO_IFC, "ifc", NULL, 0, 2, vshader_ifc, NULL, shader_glsl_ifc, WINED3DVS_VERSION(2,1), -1},
{WINED3DSIO_ELSE, "else", NULL, 0, 0, vshader_else, NULL, shader_glsl_else, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_ELSE, "else", NULL, 0, 0, vshader_else, NULL, shader_glsl_else, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_ENDIF, "endif", NULL, 0, 0, vshader_endif, NULL, shader_glsl_end, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_ENDIF, "endif", NULL, 0, 0, vshader_endif, NULL, shader_glsl_end, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_BREAK, "break", NULL, 0, 0, vshader_break, NULL, shader_glsl_break, D3DVS_VERSION(2,1), -1}, {WINED3DSIO_BREAK, "break", NULL, 0, 0, vshader_break, NULL, shader_glsl_break, WINED3DVS_VERSION(2,1), -1},
{WINED3DSIO_BREAKC, "breakc", NULL, 0, 2, vshader_breakc, NULL, shader_glsl_breakc, D3DVS_VERSION(2,1), -1}, {WINED3DSIO_BREAKC, "breakc", NULL, 0, 2, vshader_breakc, NULL, shader_glsl_breakc, WINED3DVS_VERSION(2,1), -1},
{WINED3DSIO_BREAKP, "breakp", GLNAME_REQUIRE_GLSL, 0, 1, vshader_breakp, NULL, NULL, 0, 0}, {WINED3DSIO_BREAKP, "breakp", GLNAME_REQUIRE_GLSL, 0, 1, vshader_breakp, NULL, NULL, 0, 0},
{WINED3DSIO_CALL, "call", NULL, 0, 1, vshader_call, NULL, shader_glsl_call, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_CALL, "call", NULL, 0, 1, vshader_call, NULL, shader_glsl_call, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_CALLNZ, "callnz", NULL, 0, 2, vshader_callnz, NULL, shader_glsl_callnz, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_CALLNZ, "callnz", NULL, 0, 2, vshader_callnz, NULL, shader_glsl_callnz, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_LOOP, "loop", NULL, 0, 2, vshader_loop, NULL, shader_glsl_loop, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_LOOP, "loop", NULL, 0, 2, vshader_loop, NULL, shader_glsl_loop, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_RET, "ret", NULL, 0, 0, vshader_ret, NULL, NULL, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_RET, "ret", NULL, 0, 0, vshader_ret, NULL, NULL, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_ENDLOOP, "endloop", NULL, 0, 0, vshader_endloop, NULL, shader_glsl_end, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_ENDLOOP, "endloop", NULL, 0, 0, vshader_endloop, NULL, shader_glsl_end, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_LABEL, "label", NULL, 0, 1, vshader_label, NULL, shader_glsl_label, D3DVS_VERSION(2,0), -1}, {WINED3DSIO_LABEL, "label", NULL, 0, 1, vshader_label, NULL, shader_glsl_label, WINED3DVS_VERSION(2,0), -1},
{WINED3DSIO_MOVA, "mova", GLNAME_REQUIRE_GLSL, 1, 2, vshader_mova, NULL, shader_glsl_mov, 0, 0}, {WINED3DSIO_MOVA, "mova", GLNAME_REQUIRE_GLSL, 1, 2, vshader_mova, NULL, shader_glsl_mov, 0, 0},
{WINED3DSIO_SETP, "setp", GLNAME_REQUIRE_GLSL, 1, 3, vshader_setp, NULL, NULL, 0, 0}, {WINED3DSIO_SETP, "setp", GLNAME_REQUIRE_GLSL, 1, 3, vshader_setp, NULL, NULL, 0, 0},
...@@ -567,8 +567,8 @@ static void vshader_set_limits( ...@@ -567,8 +567,8 @@ static void vshader_set_limits(
This->baseShader.limits.constant_float = GL_LIMITS(vshader_constantsF); This->baseShader.limits.constant_float = GL_LIMITS(vshader_constantsF);
switch (This->baseShader.hex_version) { switch (This->baseShader.hex_version) {
case D3DVS_VERSION(1,0): case WINED3DVS_VERSION(1,0):
case D3DVS_VERSION(1,1): case WINED3DVS_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;
...@@ -578,8 +578,8 @@ static void vshader_set_limits( ...@@ -578,8 +578,8 @@ static void vshader_set_limits(
This->baseShader.limits.label = 0; This->baseShader.limits.label = 0;
break; break;
case D3DVS_VERSION(2,0): case WINED3DVS_VERSION(2,0):
case D3DVS_VERSION(2,1): case WINED3DVS_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;
...@@ -589,7 +589,7 @@ static void vshader_set_limits( ...@@ -589,7 +589,7 @@ static void vshader_set_limits(
This->baseShader.limits.label = 16; This->baseShader.limits.label = 16;
break; break;
case D3DVS_VERSION(3,0): case WINED3DVS_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;
...@@ -727,7 +727,7 @@ static VOID IWineD3DVertexShaderImpl_GenerateShader( ...@@ -727,7 +727,7 @@ static VOID IWineD3DVertexShaderImpl_GenerateShader(
shader_generate_main( (IWineD3DBaseShader*) This, &buffer, reg_maps, pFunction); shader_generate_main( (IWineD3DBaseShader*) This, &buffer, reg_maps, pFunction);
/* Unpack 3.0 outputs */ /* Unpack 3.0 outputs */
if (This->baseShader.hex_version >= D3DVS_VERSION(3,0)) if (This->baseShader.hex_version >= WINED3DVS_VERSION(3,0))
vshader_glsl_output_unpack(&buffer, This->semantics_out); vshader_glsl_output_unpack(&buffer, This->semantics_out);
/* Clamp the fog from 0 to 1 if it's used */ /* Clamp the fog from 0 to 1 if it's used */
...@@ -893,7 +893,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_ExecuteSW(IWineD3DVertexShader* iface, W ...@@ -893,7 +893,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_ExecuteSW(IWineD3DVertexShader* iface, W
if (shader_is_vshader_version(*pToken)) { /** version */ if (shader_is_vshader_version(*pToken)) { /** version */
++pToken; ++pToken;
} }
while (D3DVS_END() != *pToken) { while (WINED3DVS_END() != *pToken) {
if (shader_is_comment(*pToken)) { /** comment */ if (shader_is_comment(*pToken)) { /** comment */
DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT; DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
++pToken; ++pToken;
......
...@@ -274,5 +274,14 @@ typedef enum _WINED3DSHADER_INSTRUCTION_OPCODE_TYPE { ...@@ -274,5 +274,14 @@ typedef enum _WINED3DSHADER_INSTRUCTION_OPCODE_TYPE {
((((commentSize) << WINED3DSI_COMMENTSIZE_SHIFT) & WINED3DSI_COMMENTSIZE_MASK) | WINED3DSIO_COMMENT) ((((commentSize) << WINED3DSI_COMMENTSIZE_SHIFT) & WINED3DSI_COMMENTSIZE_MASK) | WINED3DSIO_COMMENT)
#define WINED3DSHADER_INSTRUCTION_PREDICATED (1 << 28) #define WINED3DSHADER_INSTRUCTION_PREDICATED (1 << 28)
/** Shader version tokens, and shader end tokens **/
#define WINED3DPS_VERSION(major, minor) (0xFFFF0000 | ((major) << 8) | (minor))
#define WINED3DVS_VERSION(major, minor) (0xFFFE0000 | ((major) << 8) | (minor))
#define WINED3DSHADER_VERSION_MAJOR(version) (((version) >> 8) & 0xFF)
#define WINED3DSHADER_VERSION_MINOR(version) (((version) >> 0) & 0xFF)
#define WINED3DPS_END() 0x0000FFFF
#define WINED3DVS_END() 0x0000FFFF
#endif #endif
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