Skip to content

Commit 2361db8

Browse files
Remove instancing apart from primitive workarounds (#121)
* Remove instancing apart from primitive workarounds Signed-off-by: Isaac Marovitz <isaacryu@icloud.com> * Missing change Signed-off-by: Isaac Marovitz <isaacryu@icloud.com> --------- Signed-off-by: Isaac Marovitz <isaacryu@icloud.com>
1 parent 705ab6b commit 2361db8

1 file changed

Lines changed: 3 additions & 67 deletions

File tree

MarathonRecomp/gpu/video.cpp

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ struct PipelineState
157157
GuestShader* vertexShader = nullptr;
158158
GuestShader* pixelShader = nullptr;
159159
GuestVertexDeclaration* vertexDeclaration = nullptr;
160-
bool instancing = false;
161160
bool zEnable = true;
162161
bool zWriteEnable = true;
163162
bool stencilEnable = false;
@@ -4463,11 +4462,7 @@ static std::unique_ptr<RenderPipeline> CreateGraphicsPipeline(const PipelineStat
44634462
auto& inputSlot = inputSlots[inputSlotIndex - 1];
44644463
inputSlot.index = inputElement.slotIndex;
44654464
inputSlot.stride = pipelineState.vertexStrides[inputElement.slotIndex];
4466-
4467-
if (pipelineState.instancing && inputElement.slotIndex != 0 && inputElement.slotIndex != 15)
4468-
inputSlot.classification = RenderInputSlotClassification::PER_INSTANCE_DATA;
4469-
else
4470-
inputSlot.classification = RenderInputSlotClassification::PER_VERTEX_DATA;
4465+
inputSlot.classification = RenderInputSlotClassification::PER_VERTEX_DATA;
44714466
}
44724467

44734468
desc.inputSlots = inputSlots;
@@ -4511,7 +4506,6 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli
45114506
" vertexShader: {}\n"
45124507
" pixelShader: {}\n"
45134508
" vertexDeclaration: {:X}\n"
4514-
" instancing: {}\n"
45154509
" zEnable: {}\n"
45164510
" zWriteEnable: {}\n"
45174511
" stencilEnable: {}\n"
@@ -4554,7 +4548,6 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli
45544548
pipelineState.vertexShader->name,
45554549
pipelineState.pixelShader != nullptr ? pipelineState.pixelShader->name : "<none>",
45564550
reinterpret_cast<size_t>(pipelineState.vertexDeclaration),
4557-
pipelineState.instancing,
45584551
pipelineState.zEnable,
45594552
pipelineState.zWriteEnable,
45604553
pipelineState.stencilEnable,
@@ -4956,36 +4949,6 @@ static void SetPrimitiveType(uint32_t primitiveType)
49564949
SetDirtyValue(g_dirtyStates.pipelineState, g_pipelineState.primitiveTopology, ConvertPrimitiveType(primitiveType));
49574950
}
49584951

4959-
static uint32_t CheckInstancing()
4960-
{
4961-
uint32_t indexCount = 0;
4962-
4963-
SetDirtyValue(g_dirtyStates.pipelineState, g_pipelineState.instancing, g_pipelineState.vertexDeclaration->indexVertexStream != 0);
4964-
if (g_pipelineState.instancing)
4965-
{
4966-
// Index buffer is passed as a vertex stream
4967-
indexCount = g_vertexBufferViews[g_pipelineState.vertexDeclaration->indexVertexStream].size / 4;
4968-
}
4969-
4970-
return indexCount;
4971-
}
4972-
4973-
static void UnsetInstancingStream()
4974-
{
4975-
bool dirty = false;
4976-
uint32_t index = g_pipelineState.vertexDeclaration->indexVertexStream;
4977-
4978-
SetDirtyValue(dirty, g_vertexBufferViews[index].buffer, RenderBufferReference{});
4979-
SetDirtyValue(dirty, g_vertexBufferViews[index].size, 0u);
4980-
SetDirtyValue(dirty, g_inputSlots[index].stride, 0u);
4981-
4982-
if (dirty)
4983-
{
4984-
g_dirtyStates.vertexStreamFirst = std::min<uint8_t>(g_dirtyStates.vertexStreamFirst, index);
4985-
g_dirtyStates.vertexStreamLast = std::max<uint8_t>(g_dirtyStates.vertexStreamLast, index);
4986-
}
4987-
}
4988-
49894952
static void DrawPrimitive(GuestDevice* device, uint32_t primitiveType, uint32_t startVertex, uint32_t primitiveCount)
49904953
{
49914954
LocalRenderCommandQueue queue;
@@ -5006,26 +4969,10 @@ static void ProcDrawPrimitive(const RenderCommand& cmd)
50064969

50074970
SetPrimitiveType(args.primitiveType);
50084971

5009-
uint32_t indexCount = CheckInstancing();
5010-
if (indexCount > 0)
5011-
{
5012-
auto& vertexBufferView = g_vertexBufferViews[g_pipelineState.vertexDeclaration->indexVertexStream];
5013-
5014-
SetDirtyValue(g_dirtyStates.indices, g_indexBufferView.buffer, vertexBufferView.buffer);
5015-
SetDirtyValue(g_dirtyStates.indices, g_indexBufferView.size, vertexBufferView.size);
5016-
SetDirtyValue(g_dirtyStates.indices, g_indexBufferView.format, RenderFormat::R32_UINT);
5017-
5018-
UnsetInstancingStream();
5019-
}
5020-
50214972
FlushRenderStateForRenderThread();
50224973

50234974
auto& commandList = g_commandLists[g_frame];
5024-
5025-
if (indexCount > 0)
5026-
commandList->drawIndexedInstanced(indexCount, args.primitiveCount / indexCount, 0, 0, 0);
5027-
else
5028-
commandList->drawInstanced(args.primitiveCount, 1, args.startVertex, 0);
4975+
commandList->drawInstanced(args.primitiveCount, 1, args.startVertex, 0);
50294976
}
50304977

50314978
static void DrawIndexedPrimitive(GuestDevice* device, uint32_t primitiveType, int32_t baseVertexIndex, uint32_t startIndex, uint32_t primCount)
@@ -5047,10 +4994,6 @@ static void ProcDrawIndexedPrimitive(const RenderCommand& cmd)
50474994
{
50484995
const auto& args = cmd.drawIndexedPrimitive;
50494996

5050-
uint32_t indexCount = CheckInstancing();
5051-
if (indexCount > 0)
5052-
UnsetInstancingStream();
5053-
50544997
SetPrimitiveType(args.primitiveType);
50554998
FlushRenderStateForRenderThread();
50564999

@@ -5078,10 +5021,6 @@ static void ProcDrawPrimitiveUP(const RenderCommand& cmd)
50785021
{
50795022
const auto& args = cmd.drawPrimitiveUP;
50805023

5081-
uint32_t indexCount = CheckInstancing();
5082-
if (indexCount > 0)
5083-
UnsetInstancingStream();
5084-
50855024
SetPrimitiveType(args.primitiveType);
50865025
SetDirtyValue(g_dirtyStates.pipelineState, g_pipelineState.vertexStrides[0], uint8_t(args.vertexStreamZeroStride));
50875026

@@ -5093,7 +5032,7 @@ static void ProcDrawPrimitiveUP(const RenderCommand& cmd)
50935032
g_inputSlots[0].stride = args.vertexStreamZeroStride;
50945033
g_dirtyStates.vertexStreamFirst = 0;
50955034

5096-
indexCount = 0;
5035+
uint32_t indexCount = 0;
50975036

50985037
if (args.primitiveType == D3DPT_QUADLIST)
50995038
indexCount = g_quadIndexData.prepare(args.primitiveCount);
@@ -6809,7 +6748,6 @@ struct CompilationArgs
68096748
bool hasMoreThanOneBone{};
68106749
bool velocityMapQuickStep{};
68116750
bool objectIcon{};
6812-
bool instancing{};
68136751
};
68146752

68156753
enum class MeshLayer
@@ -7873,7 +7811,6 @@ class SDLEventListenerForPSOCaching : public SDLEventListener
78737811
"{},"
78747812
"{},"
78757813
"{},"
7876-
"{},"
78777814
"RenderBlend::{},"
78787815
"RenderBlend::{},"
78797816
"RenderCullMode::{},"
@@ -7908,7 +7845,6 @@ class SDLEventListenerForPSOCaching : public SDLEventListener
79087845
pipelineState.vertexShader->shaderCacheEntry->hash,
79097846
pipelineState.pixelShader != nullptr ? pipelineState.pixelShader->shaderCacheEntry->hash : 0,
79107847
pipelineState.vertexDeclaration->hash,
7911-
pipelineState.instancing,
79127848
pipelineState.zEnable,
79137849
pipelineState.zWriteEnable,
79147850
pipelineState.stencilEnable,

0 commit comments

Comments
 (0)