Commit 08295f4c authored by Jason Green's avatar Jason Green Committed by Alexandre Julliard

wined3d: GLSL shader cleanup patch.

- Based on comments from H. Verbeet - Changed the distinction from .rgba & .xyzw masks to only use .xyzw in GLSL shaders. They are interchangeable, and only served to make the trace look more intuitive, but they don't always apply as-is, so we'll just leave everything to .xyzw. - Got rid of the "UseProgramObjectARB(0)" call in drawprim. If there is no shader set on the next primitive, then that primitive will call UseProgramObjectARB(0) when it begins to draw.
parent deab8744
...@@ -1922,17 +1922,14 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx ...@@ -1922,17 +1922,14 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx
/* Bind the correct GLSL shader program based on the currently set vertex & pixel shaders. */ /* Bind the correct GLSL shader program based on the currently set vertex & pixel shaders. */
if (wined3d_settings.shader_mode == SHADER_GLSL) { if (wined3d_settings.shader_mode == SHADER_GLSL) {
GLhandleARB programId;
set_glsl_shader_program(iface); set_glsl_shader_program(iface);
programId = This->stateBlock->shaderPrgId; /* Start using this program ID (if it's 0, there is no shader program to use, so
* glUseProgramObjectARB(0) will disable the use of any shaders) */
if (programId != 0) { if (This->stateBlock->shaderPrgId) {
/* Start using this program ID */ TRACE_(d3d_shader)("Using GLSL program %u\n", This->stateBlock->shaderPrgId);
TRACE_(d3d_shader)("Using GLSL program %u\n", programId);
GL_EXTCALL(glUseProgramObjectARB(programId));
checkGLcall("glUseProgramObjectARB");
} }
GL_EXTCALL(glUseProgramObjectARB(This->stateBlock->shaderPrgId));
checkGLcall("glUseProgramObjectARB");
} }
if (useVertexShaderFunction) { if (useVertexShaderFunction) {
...@@ -2017,12 +2014,6 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx ...@@ -2017,12 +2014,6 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx
if (usePixelShaderFunction && wined3d_settings.shader_mode == SHADER_ARB) { if (usePixelShaderFunction && wined3d_settings.shader_mode == SHADER_ARB) {
glDisable(GL_FRAGMENT_PROGRAM_ARB); glDisable(GL_FRAGMENT_PROGRAM_ARB);
} }
/* Cleanup GLSL program */
if (wined3d_settings.shader_mode == SHADER_GLSL
&& (useVertexShaderFunction || usePixelShaderFunction)) {
GL_EXTCALL(glUseProgramObjectARB(0));
}
} }
} }
......
...@@ -271,34 +271,26 @@ void shader_glsl_get_register_name( ...@@ -271,34 +271,26 @@ void shader_glsl_get_register_name(
/* Writes the GLSL writemask for the destination register */ /* Writes the GLSL writemask for the destination register */
void shader_glsl_get_output_register_swizzle( void shader_glsl_get_output_register_swizzle(
IWineD3DBaseShader *shader,
const DWORD param, const DWORD param,
char *write_mask) { char *write_mask) {
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl*) shader;
BOOL pshader = shader_is_pshader_version(This->baseShader.hex_version);
*write_mask = 0; *write_mask = 0;
if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) { if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) {
strcat(write_mask, "."); strcat(write_mask, ".");
if (param & D3DSP_WRITEMASK_0) strcat(write_mask, pshader ? "r" : "x"); if (param & D3DSP_WRITEMASK_0) strcat(write_mask, "x");
if (param & D3DSP_WRITEMASK_1) strcat(write_mask, pshader ? "g" : "y"); if (param & D3DSP_WRITEMASK_1) strcat(write_mask, "y");
if (param & D3DSP_WRITEMASK_2) strcat(write_mask, pshader ? "b" : "z"); if (param & D3DSP_WRITEMASK_2) strcat(write_mask, "z");
if (param & D3DSP_WRITEMASK_3) strcat(write_mask, pshader ? "a" : "w"); if (param & D3DSP_WRITEMASK_3) strcat(write_mask, "w");
} }
} }
void shader_glsl_get_input_register_swizzle( void shader_glsl_get_input_register_swizzle(
IWineD3DBaseShader *shader,
const DWORD param, const DWORD param,
BOOL is_color, BOOL is_color,
char *reg_mask) { char *reg_mask) {
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl*) shader; const char swizzle_reg_chars_color_fix[] = "zyxw";
BOOL pshader = shader_is_pshader_version(This->baseShader.hex_version); const char swizzle_reg_chars[] = "xyzw";
char swizzle_reg_chars_color_fix[5];
char swizzle_reg_chars[5];
const char* swizzle_regs = NULL; const char* swizzle_regs = NULL;
/** operand input */ /** operand input */
...@@ -308,9 +300,6 @@ void shader_glsl_get_input_register_swizzle( ...@@ -308,9 +300,6 @@ void shader_glsl_get_input_register_swizzle(
DWORD swizzle_z = (swizzle >> 4) & 0x03; DWORD swizzle_z = (swizzle >> 4) & 0x03;
DWORD swizzle_w = (swizzle >> 6) & 0x03; DWORD swizzle_w = (swizzle >> 6) & 0x03;
strcpy(swizzle_reg_chars_color_fix, pshader ? "bgra" : "zyxw");
strcpy(swizzle_reg_chars, pshader ? "rgba" : "xyzw");
if (is_color) { if (is_color) {
swizzle_regs = swizzle_reg_chars_color_fix; swizzle_regs = swizzle_reg_chars_color_fix;
} else { } else {
...@@ -363,10 +352,10 @@ void shader_glsl_add_param( ...@@ -363,10 +352,10 @@ void shader_glsl_add_param(
shader_glsl_get_register_name(param, addr_token, reg_name, &is_color, arg); shader_glsl_get_register_name(param, addr_token, reg_name, &is_color, arg);
if (is_input) { if (is_input) {
shader_glsl_get_input_register_swizzle(arg->shader, param, is_color, reg_mask); shader_glsl_get_input_register_swizzle(param, is_color, reg_mask);
shader_glsl_gen_modifier(param, reg_name, reg_mask, out_str); shader_glsl_gen_modifier(param, reg_name, reg_mask, out_str);
} else { } else {
shader_glsl_get_output_register_swizzle(arg->shader, param, reg_mask); shader_glsl_get_output_register_swizzle(param, reg_mask);
sprintf(out_str, "%s%s", reg_name, reg_mask); sprintf(out_str, "%s%s", reg_name, reg_mask);
} }
} }
......
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