Change the matrix interface on RenderState so the backend doesn't have to try detect changes on each Apply
Include the texture matrix in the mesh builder
This commit is contained in:
parent
96ac7ba3f0
commit
eba0bee9f6
17 changed files with 126 additions and 136 deletions
|
|
@ -42,6 +42,10 @@ EXTERN_CVAR(Bool, r_skipmats)
|
|||
|
||||
VkRenderState::VkRenderState(VulkanRenderDevice* fb) : fb(fb), mStreamBufferWriter(fb), mMatrixBufferWriter(fb)
|
||||
{
|
||||
mMatrices.ModelMatrix.loadIdentity();
|
||||
mMatrices.NormalModelMatrix.loadIdentity();
|
||||
mMatrices.TextureMatrix.loadIdentity();
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
|
@ -411,10 +415,14 @@ void VkRenderState::ApplyPushConstants()
|
|||
|
||||
void VkRenderState::ApplyMatrices()
|
||||
{
|
||||
if (!mMatrixBufferWriter.Write(mModelMatrix, mModelMatrixEnabled, mTextureMatrix, mTextureMatrixEnabled))
|
||||
if (mMatricesChanged)
|
||||
{
|
||||
WaitForStreamBuffers();
|
||||
mMatrixBufferWriter.Write(mModelMatrix, mModelMatrixEnabled, mTextureMatrix, mTextureMatrixEnabled);
|
||||
if (!mMatrixBufferWriter.Write(mMatrices))
|
||||
{
|
||||
WaitForStreamBuffers();
|
||||
mMatrixBufferWriter.Write(mMatrices);
|
||||
}
|
||||
mMatricesChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -503,6 +511,21 @@ void VkRenderState::SetViewpoint(int index)
|
|||
mNeedApply = true;
|
||||
}
|
||||
|
||||
void VkRenderState::SetModelMatrix(const VSMatrix& matrix, const VSMatrix& normalMatrix)
|
||||
{
|
||||
mMatrices.ModelMatrix = matrix;
|
||||
mMatrices.NormalModelMatrix = normalMatrix;
|
||||
mMatricesChanged = true;
|
||||
mNeedApply = true;
|
||||
}
|
||||
|
||||
void VkRenderState::SetTextureMatrix(const VSMatrix& matrix)
|
||||
{
|
||||
mMatrices.TextureMatrix = matrix;
|
||||
mMatricesChanged = true;
|
||||
mNeedApply = true;
|
||||
}
|
||||
|
||||
int VkRenderState::UploadLights(const FDynLightData& data)
|
||||
{
|
||||
auto buffers = fb->GetBufferManager();
|
||||
|
|
@ -598,8 +621,6 @@ void VkRenderState::EndRenderPass()
|
|||
mLastViewpointOffset = 0xffffffff;
|
||||
mLastVertexBuffer = nullptr;
|
||||
mLastIndexBuffer = nullptr;
|
||||
mLastModelMatrixEnabled = true;
|
||||
mLastTextureMatrixEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue