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

wined3d: Allow use of pixel shaders with drawStridedSlow.

parent 438d88e1
...@@ -1789,122 +1789,128 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx ...@@ -1789,122 +1789,128 @@ UINT numberOfvertices, UINT numberOfIndicies, GLenum glPrimType, const void *idx
TRACE("Loaded arrays\n"); TRACE("Loaded arrays\n");
if (useVertexShaderFunction || usePixelShaderFunction) { if (useVertexShaderFunction) {
if (useVertexShaderFunction) { IWineD3DVertexDeclarationImpl *vertexDeclaration;
IWineD3DVertexDeclarationImpl *vertexDeclaration; int i;
int i;
TRACE("Using vertex shader\n");
TRACE("Using vertex shader\n");
/* Bind the vertex program */
/* Bind the vertex program */ GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB,
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.prgId)); ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.prgId));
checkGLcall("glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertexShader->prgId);"); checkGLcall("glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vertexShader->prgId);");
/* Enable OpenGL vertex programs */ /* Enable OpenGL vertex programs */
glEnable(GL_VERTEX_PROGRAM_ARB); glEnable(GL_VERTEX_PROGRAM_ARB);
checkGLcall("glEnable(GL_VERTEX_PROGRAM_ARB);"); checkGLcall("glEnable(GL_VERTEX_PROGRAM_ARB);");
TRACE_(d3d_shader)("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n", This, ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.prgId); TRACE_(d3d_shader)("(%p) : Bound vertex program %u and enabled GL_VERTEX_PROGRAM_ARB\n",
This, ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.prgId);
/* Vertex Shader 8 constants */
vertexDeclaration = (IWineD3DVertexDeclarationImpl *)((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration; /* Vertex Shader 8 constants */
if (vertexDeclaration != NULL) { vertexDeclaration = (IWineD3DVertexDeclarationImpl *)
float *constants = vertexDeclaration->constants; ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->vertexDeclaration;
if (constants != NULL) { if (vertexDeclaration != NULL) {
for (i = 0; i <= WINED3D_VSHADER_MAX_CONSTANTS; ++i) { float *constants = vertexDeclaration->constants;
TRACE_(d3d_shader)("Not loading constants %u = %f %f %f %f\n", i, constants[i * 4], constants[i * 4 + 1], constants[i * 4 + 2], constants[i * 4 + 3]); if (constants != NULL) {
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, &constants[i * 4])); for (i = 0; i <= WINED3D_VSHADER_MAX_CONSTANTS; ++i) {
} TRACE_(d3d_shader)("Not loading constants %u = %f %f %f %f\n", i,
} constants[i * 4], constants[i * 4 + 1], constants[i * 4 + 2], constants[i * 4 + 3]);
} GL_EXTCALL(glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, &constants[i * 4]));
/* Update the constants */
for (i = 0; i < WINED3D_VSHADER_MAX_CONSTANTS; ++i) {
/* TODO: add support for Integer and Boolean constants */
if (WINESHADERCNST_FLOAT == This->stateBlock->vertexShaderConstantT[i]) {
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, &This->stateBlock->vertexShaderConstantF[i * 4]));
TRACE_(d3d_shader)("Loading constants %u = %f %f %f %f\n",i, This->stateBlock->vertexShaderConstantF[i *4 ], This->stateBlock->vertexShaderConstantF[i * 4 + 1], This->stateBlock->vertexShaderConstantF[i *4 + 2], This->stateBlock->vertexShaderConstantF[i * 4 + 3]);
checkGLcall("glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB");
} }
} }
} }
if (usePixelShaderFunction) { /* Update the constants */
int i; for (i = 0; i < WINED3D_VSHADER_MAX_CONSTANTS; ++i) {
/* TODO: add support for Integer and Boolean constants */
TRACE("Using pixel shader\n"); if (WINESHADERCNST_FLOAT == This->stateBlock->vertexShaderConstantT[i]) {
/* Bind the fragment program */ GL_EXTCALL(glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i,
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.prgId)); &This->stateBlock->vertexShaderConstantF[i * 4]));
checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixelShader->prgId);");
/* Enable OpenGL fragment programs */ TRACE_(d3d_shader)("Loading constants %u = %f %f %f %f\n", i,
glEnable(GL_FRAGMENT_PROGRAM_ARB); This->stateBlock->vertexShaderConstantF[i * 4],
checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);"); This->stateBlock->vertexShaderConstantF[i * 4 + 1],
TRACE_(d3d_shader)("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n", This, ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.prgId); This->stateBlock->vertexShaderConstantF[i * 4 + 2],
This->stateBlock->vertexShaderConstantF[i * 4 + 3]);
/* Update the constants */
for (i = 0; i < WINED3D_PSHADER_MAX_CONSTANTS; ++i) {
/* TODO: add support for Integer and Boolean constants */
if (WINESHADERCNST_FLOAT == This->stateBlock->pixelShaderConstantT[i]) {
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, &This->stateBlock->pixelShaderConstantF[i * 4]));
TRACE_(d3d_shader)("Loading constants %u = %f %f %f %f\n",i, This->stateBlock->pixelShaderConstantF[i *4 ], This->stateBlock->pixelShaderConstantF[i * 4 + 1], This->stateBlock->pixelShaderConstantF[i *4 + 2], This->stateBlock->pixelShaderConstantF[i * 4 + 3]);
checkGLcall("glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB"); checkGLcall("glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB");
}
} }
} }
}
/* always draw strided fast if a vertex shader is being used */ if (usePixelShaderFunction) {
drawStridedFast(iface, numberOfIndicies, glPrimType, int i;
idxData, idxSize, minIndex, StartIdx);
TRACE("Using pixel shader\n");
/* Cleanup vertex program */
if (useVertexShaderFunction) { /* Bind the fragment program */
/* disable any attribs */ GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,
if(((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->declaredArrays) { ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.prgId));
GLint maxAttribs; checkGLcall("glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixelShader->prgId);");
int i;
/* Leave all the attribs disabled */ /* Enable OpenGL fragment programs */
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &maxAttribs); glEnable(GL_FRAGMENT_PROGRAM_ARB);
/* MESA does not support it right not */ checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB);");
if (glGetError() != GL_NO_ERROR) TRACE_(d3d_shader)("(%p) : Bound fragment program %u and enabled GL_FRAGMENT_PROGRAM_ARB\n",
maxAttribs = 16; This, ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.prgId);
for (i = 0; i < maxAttribs; ++i) {
GL_EXTCALL(glDisableVertexAttribArrayARB(i)); /* Update the constants */
checkGLcall("glDisableVertexAttribArrayARB(reg);"); for (i = 0; i < WINED3D_PSHADER_MAX_CONSTANTS; ++i) {
} /* TODO: add support for Integer and Boolean constants */
} if (WINESHADERCNST_FLOAT == This->stateBlock->pixelShaderConstantT[i]) {
GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i,
glDisable(GL_VERTEX_PROGRAM_ARB); &This->stateBlock->pixelShaderConstantF[i * 4]));
TRACE_(d3d_shader)("Loading constants %u = %f %f %f %f\n", i,
This->stateBlock->pixelShaderConstantF[i * 4],
This->stateBlock->pixelShaderConstantF[i * 4 + 1],
This->stateBlock->pixelShaderConstantF[i * 4 + 2],
This->stateBlock->pixelShaderConstantF[i * 4 + 3]);
checkGLcall("glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB");
}
} }
}
/* Cleanup fragment program */ /* DirectX colours are in a different format to opengl colours
if (usePixelShaderFunction) { * so if diffuse or specular are used then we need to use drawStridedSlow
glDisable(GL_FRAGMENT_PROGRAM_ARB); * to correct the colours */
} if (!useVertexShaderFunction &&
} else { ((dataLocations->u.s.pSize.lpData != NULL)
|| (dataLocations->u.s.diffuse.lpData != NULL)
|| (dataLocations->u.s.specular.lpData != NULL))) {
/* TODO: replace drawStridedSlow with veretx fixups */
/* DirectX colours are in a different format to opengl colours drawStridedSlow(iface, dataLocations, numberOfIndicies, glPrimType,
so if diffuse or specular are used then we need to use drawStridedSlow idxData, idxSize, minIndex, StartIdx);
to correct the colours */
if ((dataLocations->u.s.pSize.lpData != NULL)
|| (dataLocations->u.s.diffuse.lpData != NULL)
|| (dataLocations->u.s.specular.lpData != NULL)) {
/* TODO: replace drawStridedSlow with veretx fixups */
#if 1
drawStridedSlow(iface, dataLocations, numberOfIndicies, glPrimType, } else {
idxData, idxSize, minIndex, StartIdx) ; /* OpenGL can manage everything in hardware so we can use drawStridedFast */
drawStridedFast(iface, numberOfIndicies, glPrimType,
/* idxData, idxSize, minIndex, StartIdx);
* drawStridedSlow(iface, dataLocations, numberOfIndicies, glPrimType, }
* idxData, idxSize, minIndex, StartIdx);
*/ /* Cleanup vertex program */
#endif if (useVertexShaderFunction) {
} else { /* disable any attribs */
/* OpenGL can manage everything in hardware so we can use drawStridedFast */ if(((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->declaredArrays) {
drawStridedFast(iface, numberOfIndicies, glPrimType, GLint maxAttribs;
idxData, idxSize, minIndex, StartIdx); int i;
/* Leave all the attribs disabled */
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &maxAttribs);
/* MESA does not support it right not */
if (glGetError() != GL_NO_ERROR)
maxAttribs = 16;
for (i = 0; i < maxAttribs; ++i) {
GL_EXTCALL(glDisableVertexAttribArrayARB(i));
checkGLcall("glDisableVertexAttribArrayARB(reg);");
}
} }
glDisable(GL_VERTEX_PROGRAM_ARB);
}
/* Cleanup fragment program */
if (usePixelShaderFunction) {
glDisable(GL_FRAGMENT_PROGRAM_ARB);
} }
} }
} }
......
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