From 34d581f2dcffa9f54e96af230a56cb01e8e2fccd Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 16 Dec 2016 21:41:38 -0800 Subject: VideoCore/Shader: Extract input vertex loading code into function --- src/video_core/command_processor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index ea58e9f54..36f72393b 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -149,7 +149,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { if (g_debug_context) g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, static_cast(&immediate_input)); - g_state.vs.Run(shader_unit, immediate_input, regs.vs.num_input_attributes + 1); + shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); + g_state.vs.Run(shader_unit); Shader::OutputVertex output_vertex = shader_unit.output_registers.ToVertex(regs.vs); @@ -283,7 +284,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { if (g_debug_context) g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, (void*)&input); - g_state.vs.Run(shader_unit, input, loader.GetNumTotalAttributes()); + shader_unit.LoadInputVertex(input, loader.GetNumTotalAttributes()); + g_state.vs.Run(shader_unit); // Retrieve vertex from register data output_vertex = shader_unit.output_registers.ToVertex(regs.vs); -- cgit v1.2.3 From 1e1f9398176e4f1ec608f31f22a576c749a0a723 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 16 Dec 2016 22:30:00 -0800 Subject: VideoCore/Shader: Use only entry_point as ShaderSetup param This removes all implicit dependency of ShaderState on global PICA state. --- src/video_core/command_processor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 36f72393b..fc224c6f2 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -150,7 +150,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, static_cast(&immediate_input)); shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); - g_state.vs.Run(shader_unit); + g_state.vs.Run(shader_unit, regs.vs.main_offset); Shader::OutputVertex output_vertex = shader_unit.output_registers.ToVertex(regs.vs); @@ -285,7 +285,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, (void*)&input); shader_unit.LoadInputVertex(input, loader.GetNumTotalAttributes()); - g_state.vs.Run(shader_unit); + g_state.vs.Run(shader_unit, regs.vs.main_offset); // Retrieve vertex from register data output_vertex = shader_unit.output_registers.ToVertex(regs.vs); -- cgit v1.2.3 From dd4a1672a77830a53de61cf0554b34e9e17a2905 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 16 Dec 2016 23:21:26 -0800 Subject: VideoCore/Shader: Split shader uniform state and shader engine Currently there's only a single dummy implementation, which will be split in a following commit. --- src/video_core/command_processor.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index fc224c6f2..694c9f169 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -142,15 +142,16 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { MICROPROFILE_SCOPE(GPU_Drawing); immediate_attribute_id = 0; - Shader::UnitState shader_unit; - g_state.vs.Setup(); + auto* shader_engine = Shader::GetEngine(); + shader_engine->SetupBatch(&g_state.vs); // Send to vertex shader if (g_debug_context) g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, static_cast(&immediate_input)); + Shader::UnitState shader_unit; shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); - g_state.vs.Run(shader_unit, regs.vs.main_offset); + shader_engine->Run(shader_unit, regs.vs.main_offset); Shader::OutputVertex output_vertex = shader_unit.output_registers.ToVertex(regs.vs); @@ -244,8 +245,10 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { unsigned int vertex_cache_pos = 0; vertex_cache_ids.fill(-1); + auto* shader_engine = Shader::GetEngine(); Shader::UnitState shader_unit; - g_state.vs.Setup(); + + shader_engine->SetupBatch(&g_state.vs); for (unsigned int index = 0; index < regs.num_vertices; ++index) { // Indexed rendering doesn't use the start offset @@ -285,7 +288,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, (void*)&input); shader_unit.LoadInputVertex(input, loader.GetNumTotalAttributes()); - g_state.vs.Run(shader_unit, regs.vs.main_offset); + shader_engine->Run(shader_unit, regs.vs.main_offset); // Retrieve vertex from register data output_vertex = shader_unit.output_registers.ToVertex(regs.vs); -- cgit v1.2.3 From 6fa3687afc97685101f9ee5c65cf98f505980695 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 17 Dec 2016 14:38:03 -0800 Subject: Shader: Remove OutputRegisters struct --- src/video_core/command_processor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 694c9f169..66d19cba0 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -152,8 +152,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { Shader::UnitState shader_unit; shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); shader_engine->Run(shader_unit, regs.vs.main_offset); - Shader::OutputVertex output_vertex = - shader_unit.output_registers.ToVertex(regs.vs); + auto output_vertex = Shader::OutputVertex::FromRegisters( + shader_unit.registers.output, regs, regs.vs.output_mask); // Send to renderer using Pica::Shader::OutputVertex; @@ -291,7 +291,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { shader_engine->Run(shader_unit, regs.vs.main_offset); // Retrieve vertex from register data - output_vertex = shader_unit.output_registers.ToVertex(regs.vs); + output_vertex = Shader::OutputVertex::FromRegisters(shader_unit.registers.output, + regs, regs.vs.output_mask); if (is_indexed) { vertex_cache[vertex_cache_pos] = output_vertex; -- cgit v1.2.3 From 0f642741451e3f75c2f1d64ae9beccaf1437f12c Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 17 Dec 2016 16:06:04 -0800 Subject: VideoCore/Shader: Move per-batch ShaderEngine state into ShaderSetup --- src/video_core/command_processor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 66d19cba0..c3872d06c 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -143,7 +143,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { immediate_attribute_id = 0; auto* shader_engine = Shader::GetEngine(); - shader_engine->SetupBatch(&g_state.vs); + shader_engine->SetupBatch(g_state.vs); // Send to vertex shader if (g_debug_context) @@ -151,7 +151,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { static_cast(&immediate_input)); Shader::UnitState shader_unit; shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); - shader_engine->Run(shader_unit, regs.vs.main_offset); + shader_engine->Run(g_state.vs, shader_unit, regs.vs.main_offset); auto output_vertex = Shader::OutputVertex::FromRegisters( shader_unit.registers.output, regs, regs.vs.output_mask); @@ -248,7 +248,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { auto* shader_engine = Shader::GetEngine(); Shader::UnitState shader_unit; - shader_engine->SetupBatch(&g_state.vs); + shader_engine->SetupBatch(g_state.vs); for (unsigned int index = 0; index < regs.num_vertices; ++index) { // Indexed rendering doesn't use the start offset @@ -288,7 +288,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, (void*)&input); shader_unit.LoadInputVertex(input, loader.GetNumTotalAttributes()); - shader_engine->Run(shader_unit, regs.vs.main_offset); + shader_engine->Run(g_state.vs, shader_unit, regs.vs.main_offset); // Retrieve vertex from register data output_vertex = Shader::OutputVertex::FromRegisters(shader_unit.registers.output, -- cgit v1.2.3 From 0e9081b97348c65029c96697443acb0dbbc58756 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 17 Dec 2016 16:16:02 -0800 Subject: VideoCore/Shader: Move entry_point to SetupBatch --- src/video_core/command_processor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index c3872d06c..eb79974a8 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -143,7 +143,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { immediate_attribute_id = 0; auto* shader_engine = Shader::GetEngine(); - shader_engine->SetupBatch(g_state.vs); + shader_engine->SetupBatch(g_state.vs, regs.vs.main_offset); // Send to vertex shader if (g_debug_context) @@ -151,7 +151,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { static_cast(&immediate_input)); Shader::UnitState shader_unit; shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1); - shader_engine->Run(g_state.vs, shader_unit, regs.vs.main_offset); + shader_engine->Run(g_state.vs, shader_unit); auto output_vertex = Shader::OutputVertex::FromRegisters( shader_unit.registers.output, regs, regs.vs.output_mask); @@ -248,7 +248,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { auto* shader_engine = Shader::GetEngine(); Shader::UnitState shader_unit; - shader_engine->SetupBatch(g_state.vs); + shader_engine->SetupBatch(g_state.vs, regs.vs.main_offset); for (unsigned int index = 0; index < regs.num_vertices; ++index) { // Indexed rendering doesn't use the start offset @@ -288,7 +288,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation, (void*)&input); shader_unit.LoadInputVertex(input, loader.GetNumTotalAttributes()); - shader_engine->Run(g_state.vs, shader_unit, regs.vs.main_offset); + shader_engine->Run(g_state.vs, shader_unit); // Retrieve vertex from register data output_vertex = Shader::OutputVertex::FromRegisters(shader_unit.registers.output, -- cgit v1.2.3