Merge pull request #1695 from Armada651/stateman-setters

D3DState: Always update the m_pending members in the setters.
This commit is contained in:
Markus Wick 2014-12-14 03:01:34 +01:00
commit cb3a964730

View File

@ -113,52 +113,42 @@ public:
void SetTexture(u32 index, ID3D11ShaderResourceView* texture) void SetTexture(u32 index, ID3D11ShaderResourceView* texture)
{ {
if (m_current.textures[index] != texture) if (m_current.textures[index] != texture)
{
m_dirtyFlags |= DirtyFlag_Texture0 << index; m_dirtyFlags |= DirtyFlag_Texture0 << index;
m_pending.textures[index] = texture;
} m_pending.textures[index] = texture;
} }
void SetSampler(u32 index, ID3D11SamplerState* sampler) void SetSampler(u32 index, ID3D11SamplerState* sampler)
{ {
if (m_current.samplers[index] != sampler) if (m_current.samplers[index] != sampler)
{
m_dirtyFlags |= DirtyFlag_Sampler0 << index; m_dirtyFlags |= DirtyFlag_Sampler0 << index;
m_pending.samplers[index] = sampler;
} m_pending.samplers[index] = sampler;
} }
void SetPixelConstants(ID3D11Buffer* buffer0, ID3D11Buffer* buffer1 = nullptr) void SetPixelConstants(ID3D11Buffer* buffer0, ID3D11Buffer* buffer1 = nullptr)
{ {
if (m_current.pixelConstants[0] != buffer0) if (m_current.pixelConstants[0] != buffer0 || m_current.pixelConstants[1] != buffer1)
{
m_dirtyFlags |= DirtyFlag_PixelConstants; m_dirtyFlags |= DirtyFlag_PixelConstants;
m_pending.pixelConstants[0] = buffer0;
}
if (m_current.pixelConstants[1] != buffer1) m_pending.pixelConstants[0] = buffer0;
{ m_pending.pixelConstants[1] = buffer1;
m_dirtyFlags |= DirtyFlag_PixelConstants;
m_pending.pixelConstants[1] = buffer1;
}
} }
void SetVertexConstants(ID3D11Buffer* buffer) void SetVertexConstants(ID3D11Buffer* buffer)
{ {
if (m_current.vertexConstants != buffer) if (m_current.vertexConstants != buffer)
{
m_dirtyFlags |= DirtyFlag_VertexConstants; m_dirtyFlags |= DirtyFlag_VertexConstants;
m_pending.vertexConstants = buffer;
} m_pending.vertexConstants = buffer;
} }
void SetGeometryConstants(ID3D11Buffer* buffer) void SetGeometryConstants(ID3D11Buffer* buffer)
{ {
if (m_current.geometryConstants != buffer) if (m_current.geometryConstants != buffer)
{
m_dirtyFlags |= DirtyFlag_GeometryConstants; m_dirtyFlags |= DirtyFlag_GeometryConstants;
m_pending.geometryConstants = buffer;
} m_pending.geometryConstants = buffer;
} }
void SetVertexBuffer(ID3D11Buffer* buffer, u32 stride, u32 offset) void SetVertexBuffer(ID3D11Buffer* buffer, u32 stride, u32 offset)
@ -166,72 +156,66 @@ public:
if (m_current.vertexBuffer != buffer || if (m_current.vertexBuffer != buffer ||
m_current.vertexBufferStride != stride || m_current.vertexBufferStride != stride ||
m_current.vertexBufferOffset != offset) m_current.vertexBufferOffset != offset)
{
m_dirtyFlags |= DirtyFlag_VertexBuffer; m_dirtyFlags |= DirtyFlag_VertexBuffer;
m_pending.vertexBuffer = buffer;
m_pending.vertexBufferStride = stride; m_pending.vertexBuffer = buffer;
m_pending.vertexBufferOffset = offset; m_pending.vertexBufferStride = stride;
} m_pending.vertexBufferOffset = offset;
} }
void SetIndexBuffer(ID3D11Buffer* buffer) void SetIndexBuffer(ID3D11Buffer* buffer)
{ {
if (m_current.indexBuffer != buffer) if (m_current.indexBuffer != buffer)
{
m_dirtyFlags |= DirtyFlag_IndexBuffer; m_dirtyFlags |= DirtyFlag_IndexBuffer;
m_pending.indexBuffer = buffer;
} m_pending.indexBuffer = buffer;
} }
void SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY topology) void SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY topology)
{ {
if (m_current.topology != topology) if (m_current.topology != topology)
{
m_dirtyFlags |= DirtyFlag_InputAssembler; m_dirtyFlags |= DirtyFlag_InputAssembler;
m_pending.topology = topology;
} m_pending.topology = topology;
} }
void SetInputLayout(ID3D11InputLayout* layout) void SetInputLayout(ID3D11InputLayout* layout)
{ {
if (m_current.inputLayout != layout) if (m_current.inputLayout != layout)
{
m_dirtyFlags |= DirtyFlag_InputAssembler; m_dirtyFlags |= DirtyFlag_InputAssembler;
m_pending.inputLayout = layout;
} m_pending.inputLayout = layout;
} }
void SetPixelShader(ID3D11PixelShader* shader) void SetPixelShader(ID3D11PixelShader* shader)
{ {
if (m_current.pixelShader != shader) if (m_current.pixelShader != shader)
{
m_dirtyFlags |= DirtyFlag_PixelShader; m_dirtyFlags |= DirtyFlag_PixelShader;
m_pending.pixelShader = shader;
} m_pending.pixelShader = shader;
} }
void SetPixelShaderDynamic(ID3D11PixelShader* shader, ID3D11ClassInstance * const * classInstances, u32 classInstancesCount) void SetPixelShaderDynamic(ID3D11PixelShader* shader, ID3D11ClassInstance * const * classInstances, u32 classInstancesCount)
{ {
D3D::context->PSSetShader(shader, classInstances, classInstancesCount); D3D::context->PSSetShader(shader, classInstances, classInstancesCount);
m_current.pixelShader = shader;
m_pending.pixelShader = shader; m_pending.pixelShader = shader;
} }
void SetVertexShader(ID3D11VertexShader* shader) void SetVertexShader(ID3D11VertexShader* shader)
{ {
if (m_current.vertexShader != shader) if (m_current.vertexShader != shader)
{
m_dirtyFlags |= DirtyFlag_VertexShader; m_dirtyFlags |= DirtyFlag_VertexShader;
m_pending.vertexShader = shader;
} m_pending.vertexShader = shader;
} }
void SetGeometryShader(ID3D11GeometryShader* shader) void SetGeometryShader(ID3D11GeometryShader* shader)
{ {
if (m_current.geometryShader != shader) if (m_current.geometryShader != shader)
{
m_dirtyFlags |= DirtyFlag_GeometryShader; m_dirtyFlags |= DirtyFlag_GeometryShader;
m_pending.geometryShader = shader;
} m_pending.geometryShader = shader;
} }
// call this immediately before any drawing operation or to explicitly apply pending resource state changes // call this immediately before any drawing operation or to explicitly apply pending resource state changes