Remove the ConstantTable member variables

Trac #22155 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Since we no longer keep them as member variables, we need to make sure we delete them before leaving the function. This made it necessary to reflow some of the logic. We can now attempt more parts of linking even if it will ultimately fail, but sometimes the partial link information is useful (ie for attributes). git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1502 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent a418ef12
......@@ -69,8 +69,6 @@ ProgramBinary::ProgramBinary(rx::Renderer *renderer) : RefCountObject(0), mSeria
mPixelExecutable = NULL;
mVertexExecutable = NULL;
mConstantTablePS = NULL;
mConstantTableVS = NULL;
mValidated = false;
......@@ -112,9 +110,6 @@ ProgramBinary::~ProgramBinary()
mVertexExecutable->Release();
}
delete mConstantTablePS;
delete mConstantTableVS;
while (!mUniforms.empty())
{
delete mUniforms.back();
......@@ -1933,56 +1928,65 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
const char *vertexProfile = mRenderer->getMajorShaderModel() >= 3 ? "vs_3_0" : "vs_2_0";
const char *pixelProfile = mRenderer->getMajorShaderModel() >= 3 ? "ps_3_0" : "ps_2_0";
ID3D10Blob *vertexBinary = compileToBinary(infoLog, vertexHLSL.c_str(), vertexProfile, &mConstantTableVS);
ID3D10Blob *pixelBinary = compileToBinary(infoLog, pixelHLSL.c_str(), pixelProfile, &mConstantTablePS);
bool success = true;
D3DConstantTable *constantTableVS = NULL;
D3DConstantTable *constantTablePS = NULL;
ID3D10Blob *vertexBinary = compileToBinary(infoLog, vertexHLSL.c_str(), vertexProfile, &constantTableVS);
ID3D10Blob *pixelBinary = compileToBinary(infoLog, pixelHLSL.c_str(), pixelProfile, &constantTablePS);
if (vertexBinary && pixelBinary)
{
mVertexExecutable = mRenderer->createVertexShader((DWORD*)vertexBinary->GetBufferPointer(), vertexBinary->GetBufferSize());
if (!mVertexExecutable)
{
return error(GL_OUT_OF_MEMORY, false);
}
mPixelExecutable = mRenderer->createPixelShader((DWORD*)pixelBinary->GetBufferPointer(), pixelBinary->GetBufferSize());
if (!mPixelExecutable)
if (!mPixelExecutable || !mVertexExecutable)
{
mVertexExecutable->Release();
if (mVertexExecutable) mVertexExecutable->Release();
mVertexExecutable = NULL;
return error(GL_OUT_OF_MEMORY, false);
if (mPixelExecutable) mPixelExecutable->Release();
mPixelExecutable = NULL;
infoLog.append("Failed to create D3D shaders.");
success = false;
}
}
else
{
success = false;
}
vertexBinary->Release();
pixelBinary->Release();
vertexBinary = NULL;
pixelBinary = NULL;
if (vertexBinary) vertexBinary->Release();
if (pixelBinary) pixelBinary->Release();
vertexBinary = NULL;
pixelBinary = NULL;
if (!linkAttributes(infoLog, attributeBindings, fragmentShader, vertexShader))
{
return false;
}
if (!linkAttributes(infoLog, attributeBindings, fragmentShader, vertexShader))
{
success = false;
}
if (!linkUniforms(infoLog, mConstantTableVS, mConstantTablePS))
if (constantTableVS && constantTablePS)
{
if (!linkUniforms(infoLog, constantTableVS, constantTablePS))
{
return false;
success = false;
}
}
delete constantTableVS;
delete constantTablePS;
// these uniforms are searched as already-decorated because gl_ and dx_
// are reserved prefixes, and do not receive additional decoration
mDxDepthRangeLocation = getUniformLocation("dx_DepthRange");
mDxDepthLocation = getUniformLocation("dx_Depth");
mDxCoordLocation = getUniformLocation("dx_Coord");
mDxHalfPixelSizeLocation = getUniformLocation("dx_HalfPixelSize");
mDxFrontCCWLocation = getUniformLocation("dx_FrontCCW");
mDxPointsOrLinesLocation = getUniformLocation("dx_PointsOrLines");
Context *context = getContext();
context->markDxUniformsDirty();
// these uniforms are searched as already-decorated because gl_ and dx_
// are reserved prefixes, and do not receive additional decoration
mDxDepthRangeLocation = getUniformLocation("dx_DepthRange");
mDxDepthLocation = getUniformLocation("dx_Depth");
mDxCoordLocation = getUniformLocation("dx_Coord");
mDxHalfPixelSizeLocation = getUniformLocation("dx_HalfPixelSize");
mDxFrontCCWLocation = getUniformLocation("dx_FrontCCW");
mDxPointsOrLinesLocation = getUniformLocation("dx_PointsOrLines");
return true;
}
Context *context = getContext();
context->markDxUniformsDirty();
return false;
return success;
}
// Determines the mapping between GL attributes and Direct3D 9 vertex stream usage indices
......
......@@ -192,10 +192,6 @@ class ProgramBinary : public RefCountObject
IDirect3DPixelShader9 *mPixelExecutable; // D3D9_REPLACE
IDirect3DVertexShader9 *mVertexExecutable; // D3D9_REPLACE
// These are only used during linking.
D3DConstantTable *mConstantTablePS;
D3DConstantTable *mConstantTableVS;
Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
int mSemanticIndex[MAX_VERTEX_ATTRIBS];
......
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