Commit c6354ee5 by Geoff Lang

Cache applied constant buffers.

Issue #451 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang
parent 1f53cab0
...@@ -633,7 +633,12 @@ bool Renderer11::setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], con ...@@ -633,7 +633,12 @@ bool Renderer11::setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], con
return false; return false;
} }
vertexConstantBuffers[uniformBufferIndex] = constantBuffer; if (mCurrentConstantBufferVS[uniformBufferIndex] != bufferStorage->getSerial())
{
mDeviceContext->VSSetConstantBuffers(getReservedVertexUniformBuffers() + uniformBufferIndex,
1, &constantBuffer);
mCurrentConstantBufferVS[uniformBufferIndex] = bufferStorage->getSerial();
}
} }
} }
...@@ -650,13 +655,17 @@ bool Renderer11::setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], con ...@@ -650,13 +655,17 @@ bool Renderer11::setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], con
return false; return false;
} }
if (mCurrentConstantBufferPS[uniformBufferIndex] != bufferStorage->getSerial())
{
mDeviceContext->PSSetConstantBuffers(getReservedFragmentUniformBuffers() + uniformBufferIndex,
1, &constantBuffer);
mCurrentConstantBufferPS[uniformBufferIndex] = bufferStorage->getSerial();
}
pixelConstantBuffers[uniformBufferIndex] = constantBuffer; pixelConstantBuffers[uniformBufferIndex] = constantBuffer;
} }
} }
mDeviceContext->VSSetConstantBuffers(getReservedVertexUniformBuffers(), getMaxVertexShaderUniformBuffers(), vertexConstantBuffers);
mDeviceContext->PSSetConstantBuffers(getReservedFragmentUniformBuffers(), getMaxFragmentShaderUniformBuffers(), pixelConstantBuffers);
return true; return true;
} }
...@@ -1463,8 +1472,17 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra ...@@ -1463,8 +1472,17 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra
mDeviceContext->Unmap(pixelConstantBuffer, 0); mDeviceContext->Unmap(pixelConstantBuffer, 0);
} }
if (mCurrentVertexConstantBuffer != vertexConstantBuffer)
{
mDeviceContext->VSSetConstantBuffers(0, 1, &vertexConstantBuffer); mDeviceContext->VSSetConstantBuffers(0, 1, &vertexConstantBuffer);
mCurrentVertexConstantBuffer = vertexConstantBuffer;
}
if (mCurrentPixelConstantBuffer != pixelConstantBuffer)
{
mDeviceContext->PSSetConstantBuffers(0, 1, &pixelConstantBuffer); mDeviceContext->PSSetConstantBuffers(0, 1, &pixelConstantBuffer);
mCurrentPixelConstantBuffer = pixelConstantBuffer;
}
// Driver uniforms // Driver uniforms
if (!mDriverConstantBufferVS) if (!mDriverConstantBufferVS)
...@@ -1512,7 +1530,11 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra ...@@ -1512,7 +1530,11 @@ void Renderer11::applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArra
} }
// needed for the point sprite geometry shader // needed for the point sprite geometry shader
if (mCurrentGeometryConstantBuffer != mDriverConstantBufferPS)
{
mDeviceContext->GSSetConstantBuffers(0, 1, &mDriverConstantBufferPS); mDeviceContext->GSSetConstantBuffers(0, 1, &mDriverConstantBufferPS);
mCurrentGeometryConstantBuffer = mDriverConstantBufferPS;
}
} }
void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) void Renderer11::clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer)
...@@ -1821,6 +1843,16 @@ void Renderer11::markAllStateDirty() ...@@ -1821,6 +1843,16 @@ void Renderer11::markAllStateDirty()
memset(&mAppliedPixelConstants, 0, sizeof(dx_PixelConstants)); memset(&mAppliedPixelConstants, 0, sizeof(dx_PixelConstants));
mInputLayoutCache.markDirty(); mInputLayoutCache.markDirty();
for (unsigned int i = 0; i < gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS; i++)
{
mCurrentConstantBufferVS[i] = -1;
mCurrentConstantBufferPS[i] = -1;
}
mCurrentVertexConstantBuffer = NULL;
mCurrentPixelConstantBuffer = NULL;
mCurrentGeometryConstantBuffer = NULL;
} }
void Renderer11::releaseDeviceResources() void Renderer11::releaseDeviceResources()
......
...@@ -327,10 +327,16 @@ class Renderer11 : public Renderer ...@@ -327,10 +327,16 @@ class Renderer11 : public Renderer
dx_VertexConstants mVertexConstants; dx_VertexConstants mVertexConstants;
dx_VertexConstants mAppliedVertexConstants; dx_VertexConstants mAppliedVertexConstants;
ID3D11Buffer *mDriverConstantBufferVS; ID3D11Buffer *mDriverConstantBufferVS;
ID3D11Buffer *mCurrentVertexConstantBuffer;
unsigned int mCurrentConstantBufferVS[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS];
dx_PixelConstants mPixelConstants; dx_PixelConstants mPixelConstants;
dx_PixelConstants mAppliedPixelConstants; dx_PixelConstants mAppliedPixelConstants;
ID3D11Buffer *mDriverConstantBufferPS; ID3D11Buffer *mDriverConstantBufferPS;
ID3D11Buffer *mCurrentPixelConstantBuffer;
unsigned int mCurrentConstantBufferPS[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS];
ID3D11Buffer *mCurrentGeometryConstantBuffer;
// Vertex, index and input layouts // Vertex, index and input layouts
VertexDataManager *mVertexDataManager; VertexDataManager *mVertexDataManager;
......
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