Commit aed9305c authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Store shader IDs in the vs and ps impl structures.

parent dd890554
......@@ -1878,7 +1878,7 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
TRACE("Using vertex shader\n");
IWineD3DVertexShaderImpl_CompileShader(This->stateBlock->vertexShader);
priv->current_vprogram_id = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.prgId;
priv->current_vprogram_id = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->prgId;
/* Bind the vertex program */
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id));
......@@ -1900,7 +1900,7 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
find_ps_compile_args((IWineD3DPixelShaderImpl *) This->stateBlock->pixelShader, This->stateBlock, &compile_args);
pixelshader_compile(This->stateBlock->pixelShader, &compile_args);
priv->current_fprogram_id = ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.prgId;
priv->current_fprogram_id = ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->prgId;
/* Bind the fragment program */
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id));
......@@ -1980,12 +1980,21 @@ static void shader_arb_cleanup(IWineD3DDevice *iface) {
static void shader_arb_destroy(IWineD3DBaseShader *iface) {
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) iface;
WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *) This->baseShader.device)->adapter->gl_info;
char pshader = shader_is_pshader_version(This->baseShader.hex_version);
ENTER_GL();
GL_EXTCALL(glDeleteProgramsARB(1, &This->baseShader.prgId));
checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &This->baseShader.prgId))");
LEAVE_GL();
This->baseShader.prgId = 0;
if(pshader) {
ENTER_GL();
GL_EXTCALL(glDeleteProgramsARB(1, &((IWineD3DPixelShaderImpl *) This)->prgId));
checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &((IWineD3DPixelShaderImpl *) This)->prgId))");
((IWineD3DPixelShaderImpl *) This)->prgId = 0;
LEAVE_GL();
} else {
ENTER_GL();
GL_EXTCALL(glDeleteProgramsARB(1, &((IWineD3DVertexShaderImpl *) This)->prgId));
checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &((IWineD3DPixelShaderImpl *) This)->prgId))");
((IWineD3DVertexShaderImpl *) This)->prgId = 0;
LEAVE_GL();
}
This->baseShader.is_compiled = FALSE;
}
......@@ -2093,12 +2102,12 @@ static void shader_arb_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFE
shader_addline(buffer, "END\n");
/* TODO: change to resource.glObjectHandle or something like that */
GL_EXTCALL(glGenProgramsARB(1, &This->baseShader.prgId));
GL_EXTCALL(glGenProgramsARB(1, &This->prgId));
TRACE("Creating a hw pixel shader, prg=%d\n", This->baseShader.prgId);
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, This->baseShader.prgId));
TRACE("Creating a hw pixel shader, prg=%d\n", This->prgId);
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, This->prgId));
TRACE("Created hw pixel shader, prg=%d\n", This->baseShader.prgId);
TRACE("Created hw pixel shader, prg=%d\n", This->prgId);
/* Create the program and check for errors */
GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
buffer->bsize, buffer->buffer));
......@@ -2108,7 +2117,7 @@ static void shader_arb_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFE
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos);
FIXME("HW PixelShader Error at position %d: %s\n",
errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
This->baseShader.prgId = -1;
This->prgId = -1;
}
/* Load immediate constants */
......@@ -2199,12 +2208,12 @@ static void shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFF
shader_addline(buffer, "END\n");
/* TODO: change to resource.glObjectHandle or something like that */
GL_EXTCALL(glGenProgramsARB(1, &This->baseShader.prgId));
GL_EXTCALL(glGenProgramsARB(1, &This->prgId));
TRACE("Creating a hw vertex shader, prg=%d\n", This->baseShader.prgId);
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, This->baseShader.prgId));
TRACE("Creating a hw vertex shader, prg=%d\n", This->prgId);
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, This->prgId));
TRACE("Created hw vertex shader, prg=%d\n", This->baseShader.prgId);
TRACE("Created hw vertex shader, prg=%d\n", This->prgId);
/* Create the program and check for errors */
GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
buffer->bsize, buffer->buffer));
......@@ -2214,7 +2223,7 @@ static void shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFF
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos);
FIXME("HW VertexShader Error at position %d: %s\n",
errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
This->baseShader.prgId = -1;
This->prgId = -1;
}
/* Load immediate constants */
......
......@@ -3229,7 +3229,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
if(use_vs) {
IWineD3DVertexShaderImpl_CompileShader(vshader);
vshader_id = ((IWineD3DBaseShaderImpl*)vshader)->baseShader.prgId;
vshader_id = ((IWineD3DVertexShaderImpl*)vshader)->prgId;
} else {
vshader_id = 0;
}
......@@ -3237,7 +3237,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
struct ps_compile_args compile_args;
find_ps_compile_args((IWineD3DPixelShaderImpl*)This->stateBlock->pixelShader, This->stateBlock, &compile_args);
pixelshader_compile(pshader, &compile_args);
pshader_id = ((IWineD3DBaseShaderImpl*)pshader)->baseShader.prgId;
pshader_id = ((IWineD3DPixelShaderImpl*)pshader)->prgId;
} else {
pshader_id = 0;
}
......@@ -3535,13 +3535,19 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device;
struct shader_glsl_priv *priv = (struct shader_glsl_priv *)device->shader_priv;
WineD3D_GL_Info *gl_info = &device->adapter->gl_info;
GLuint *prog;
/* Note: Do not use QueryInterface here to find out which shader type this is because this code
* can be called from IWineD3DBaseShader::Release
*/
char pshader = shader_is_pshader_version(This->baseShader.hex_version);
if(This->baseShader.prgId == 0) return;
if(pshader) {
prog = &((IWineD3DPixelShaderImpl *) This)->prgId;
} else {
prog = &((IWineD3DVertexShaderImpl *) This)->prgId;
}
if(*prog == 0) return;
linked_programs = &This->baseShader.linked_programs;
TRACE("Deleting linked programs\n");
......@@ -3559,10 +3565,10 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
}
}
TRACE("Deleting shader object %u\n", This->baseShader.prgId);
GL_EXTCALL(glDeleteObjectARB(This->baseShader.prgId));
TRACE("Deleting shader object %u\n", *prog);
GL_EXTCALL(glDeleteObjectARB(*prog));
checkGLcall("glDeleteObjectARB");
This->baseShader.prgId = 0;
*prog = 0;
This->baseShader.is_compiled = FALSE;
}
......@@ -3627,7 +3633,7 @@ static void shader_glsl_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFF
const char *fragcolor;
WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
/* Create the hw GLSL shader object and assign it as the baseShader.prgId */
/* Create the hw GLSL shader object and assign it as the shader->prgId */
GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB));
shader_addline(buffer, "#version 120\n");
......@@ -3705,7 +3711,7 @@ static void shader_glsl_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFF
print_glsl_info_log(&GLINFO_LOCATION, shader_obj);
/* Store the shader object */
This->baseShader.prgId = shader_obj;
This->prgId = shader_obj;
}
static void shader_glsl_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer) {
......@@ -3714,7 +3720,7 @@ static void shader_glsl_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUF
CONST DWORD *function = This->baseShader.function;
WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
/* Create the hw GLSL shader program and assign it as the baseShader.prgId */
/* Create the hw GLSL shader program and assign it as the shader->prgId */
GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB));
shader_addline(buffer, "#version 120\n");
......@@ -3762,7 +3768,7 @@ static void shader_glsl_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUF
print_glsl_info_log(&GLINFO_LOCATION, shader_obj);
/* Store the shader object */
This->baseShader.prgId = shader_obj;
This->prgId = shader_obj;
}
static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct shader_caps *pCaps) {
......
......@@ -2138,7 +2138,6 @@ typedef struct IWineD3DBaseShaderClass
CONST SHADER_OPCODE *shader_ins;
DWORD *function;
UINT functionLength;
GLuint prgId;
BOOL is_compiled;
UINT cur_loop_depth, cur_loop_regno;
BOOL load_local_constsF;
......@@ -2305,6 +2304,9 @@ typedef struct IWineD3DVertexShaderImpl {
DWORD usage;
/* The GL shader */
GLuint prgId;
/* Vertex shader input and output semantics */
semantic semantics_in [MAX_ATTRIBS];
semantic semantics_out [MAX_REG_OUTPUT];
......@@ -2362,6 +2364,9 @@ typedef struct IWineD3DPixelShaderImpl {
BOOL input_reg_used[MAX_REG_INPUT];
int declared_in_count;
/* The GL shader */
GLuint prgId;
/* Some information about the shader behavior */
struct stb_const_desc bumpenvmatconst[MAX_TEXTURES];
char numbumpenvmatconsts;
......
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