Skip to content

Instantly share code, notes, and snippets.

@Subv
Created November 12, 2017 20:58
Show Gist options
  • Save Subv/117abe13a3da681fa64e72b2b904569c to your computer and use it in GitHub Desktop.
Save Subv/117abe13a3da681fa64e72b2b904569c to your computer and use it in GitHub Desktop.
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index caf9f7a0..acffc5b9 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -255,7 +255,7 @@ static void Draw(u32 command_id) {
const size_t VERTEX_CACHE_SIZE = 32;
std::array<u16, VERTEX_CACHE_SIZE> vertex_cache_ids;
std::array<Shader::AttributeBuffer, VERTEX_CACHE_SIZE> vertex_cache;
- Shader::AttributeBuffer vs_output;
+ Shader::AttributeBuffer* vs_output = nullptr;
unsigned int vertex_cache_pos = 0;
vertex_cache_ids.fill(-1);
@@ -263,11 +263,13 @@ static void Draw(u32 command_id) {
auto* shader_engine = Shader::GetEngine();
Shader::UnitState shader_unit;
+ auto& geometry_pipeline = g_state.geometry_pipeline;
+
shader_engine->SetupBatch(g_state.vs, regs.vs.main_offset);
- g_state.geometry_pipeline.Reconfigure();
- g_state.geometry_pipeline.Setup(shader_engine);
- if (g_state.geometry_pipeline.NeedIndexInput())
+ geometry_pipeline.Reconfigure();
+ geometry_pipeline.Setup(shader_engine);
+ if (geometry_pipeline.NeedIndexInput())
ASSERT(is_indexed);
for (unsigned int index = 0; index < regs.pipeline.num_vertices; ++index) {
@@ -283,8 +285,8 @@ static void Draw(u32 command_id) {
bool vertex_cache_hit = false;
if (is_indexed) {
- if (g_state.geometry_pipeline.NeedIndexInput()) {
- g_state.geometry_pipeline.SubmitIndex(vertex);
+ if (geometry_pipeline.NeedIndexInput()) {
+ geometry_pipeline.SubmitIndex(vertex);
continue;
}
@@ -295,7 +297,7 @@ static void Draw(u32 command_id) {
for (unsigned int i = 0; i < VERTEX_CACHE_SIZE; ++i) {
if (vertex == vertex_cache_ids[i]) {
- vs_output = vertex_cache[i];
+ vs_output = &vertex_cache[i];
vertex_cache_hit = true;
break;
}
@@ -313,17 +315,18 @@ static void Draw(u32 command_id) {
(void*)&input);
shader_unit.LoadInput(regs.vs, input);
shader_engine->Run(g_state.vs, shader_unit);
- shader_unit.WriteOutput(regs.vs, vs_output);
+
+ vs_output = &vertex_cache[vertex_cache_pos];
+ shader_unit.WriteOutput(regs.vs, *vs_output);
if (is_indexed) {
- vertex_cache[vertex_cache_pos] = vs_output;
vertex_cache_ids[vertex_cache_pos] = vertex;
vertex_cache_pos = (vertex_cache_pos + 1) % VERTEX_CACHE_SIZE;
}
}
// Send to geometry pipeline
- g_state.geometry_pipeline.SubmitVertex(vs_output);
+ geometry_pipeline.SubmitVertex(*vs_output);
}
for (auto& range : memory_accesses.ranges) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment