GPU: Refactor "VertexShader" namespace to "Shader".

- Also renames "vertex_shader.*" to "shader_interpreter.*"
This commit is contained in:
bunnei 2015-07-21 19:04:05 -04:00
parent cebf245504
commit 642b9b5030
14 changed files with 49 additions and 51 deletions

View file

@ -8,7 +8,7 @@
#include <QBoxLayout> #include <QBoxLayout>
#include <QTreeView> #include <QTreeView>
#include "video_core/vertex_shader.h" #include "video_core/shader_interpreter.h"
#include "graphics_vertex_shader.h" #include "graphics_vertex_shader.h"

View file

@ -11,8 +11,8 @@ set(SRCS
pica.cpp pica.cpp
primitive_assembly.cpp primitive_assembly.cpp
rasterizer.cpp rasterizer.cpp
shader_interpreter.cpp
utils.cpp utils.cpp
vertex_shader.cpp
video_core.cpp video_core.cpp
) )
@ -35,8 +35,8 @@ set(HEADERS
primitive_assembly.h primitive_assembly.h
rasterizer.h rasterizer.h
renderer_base.h renderer_base.h
shader_interpreter.h
utils.h utils.h
vertex_shader.h
video_core.h video_core.h
) )

View file

@ -7,7 +7,7 @@
#include "clipper.h" #include "clipper.h"
#include "pica.h" #include "pica.h"
#include "rasterizer.h" #include "rasterizer.h"
#include "vertex_shader.h" #include "shader_interpreter.h"
namespace Pica { namespace Pica {

View file

@ -6,13 +6,13 @@
namespace Pica { namespace Pica {
namespace VertexShader { namespace Shader {
struct OutputVertex; struct OutputVertex;
} }
namespace Clipper { namespace Clipper {
using VertexShader::OutputVertex; using Shader::OutputVertex;
void ProcessTriangle(OutputVertex& v0, OutputVertex& v1, OutputVertex& v2); void ProcessTriangle(OutputVertex& v0, OutputVertex& v1, OutputVertex& v2);

View file

@ -18,7 +18,7 @@
#include "pica.h" #include "pica.h"
#include "primitive_assembly.h" #include "primitive_assembly.h"
#include "renderer_base.h" #include "renderer_base.h"
#include "vertex_shader.h" #include "shader_interpreter.h"
#include "video_core.h" #include "video_core.h"
namespace Pica { namespace Pica {
@ -165,7 +165,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
DebugUtils::GeometryDumper geometry_dumper; DebugUtils::GeometryDumper geometry_dumper;
PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex> dumping_primitive_assembler(regs.triangle_topology.Value()); PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex> dumping_primitive_assembler(regs.triangle_topology.Value());
#endif #endif
PrimitiveAssembler<VertexShader::OutputVertex> primitive_assembler(regs.triangle_topology.Value()); PrimitiveAssembler<Shader::OutputVertex> primitive_assembler(regs.triangle_topology.Value());
if (g_debug_context) { if (g_debug_context) {
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
@ -210,7 +210,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
// The size has been tuned for optimal balance between hit-rate and the cost of lookup // The size has been tuned for optimal balance between hit-rate and the cost of lookup
const size_t VERTEX_CACHE_SIZE = 32; const size_t VERTEX_CACHE_SIZE = 32;
std::array<u16, VERTEX_CACHE_SIZE> vertex_cache_ids; std::array<u16, VERTEX_CACHE_SIZE> vertex_cache_ids;
std::array<VertexShader::OutputVertex, VERTEX_CACHE_SIZE> vertex_cache; std::array<Shader::OutputVertex, VERTEX_CACHE_SIZE> vertex_cache;
unsigned int vertex_cache_pos = 0; unsigned int vertex_cache_pos = 0;
vertex_cache_ids.fill(-1); vertex_cache_ids.fill(-1);
@ -224,7 +224,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
ASSERT(vertex != -1); ASSERT(vertex != -1);
bool vertex_cache_hit = false; bool vertex_cache_hit = false;
VertexShader::OutputVertex output; Shader::OutputVertex output;
if (is_indexed) { if (is_indexed) {
if (g_debug_context && Pica::g_debug_context->recorder) { if (g_debug_context && Pica::g_debug_context->recorder) {
@ -243,7 +243,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
if (!vertex_cache_hit) { if (!vertex_cache_hit) {
// Initialize data for the current vertex // Initialize data for the current vertex
VertexShader::InputVertex input; Shader::InputVertex input;
for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) { for (int i = 0; i < attribute_config.GetNumTotalAttributes(); ++i) {
if (vertex_attribute_elements[i] != 0) { if (vertex_attribute_elements[i] != 0) {
@ -306,9 +306,8 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
std::bind(&DebugUtils::GeometryDumper::AddTriangle, std::bind(&DebugUtils::GeometryDumper::AddTriangle,
&geometry_dumper, _1, _2, _3)); &geometry_dumper, _1, _2, _3));
#endif #endif
// Send to vertex shader // Send to vertex shader
output = VertexShader::RunShader(input, attribute_config.GetNumTotalAttributes(), g_state.regs.vs, g_state.vs); output = Shader::RunShader(input, attribute_config.GetNumTotalAttributes(), g_state.regs.vs, g_state.vs);
if (is_indexed) { if (is_indexed) {
vertex_cache[vertex_cache_pos] = output; vertex_cache[vertex_cache_pos] = output;
@ -319,9 +318,9 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
if (Settings::values.use_hw_renderer) { if (Settings::values.use_hw_renderer) {
// Send to hardware renderer // Send to hardware renderer
static auto AddHWTriangle = [](const Pica::VertexShader::OutputVertex& v0, static auto AddHWTriangle = [](const Pica::Shader::OutputVertex& v0,
const Pica::VertexShader::OutputVertex& v1, const Pica::Shader::OutputVertex& v1,
const Pica::VertexShader::OutputVertex& v2) { const Pica::Shader::OutputVertex& v2) {
VideoCore::g_renderer->hw_rasterizer->AddTriangle(v0, v1, v2); VideoCore::g_renderer->hw_rasterizer->AddTriangle(v0, v1, v2);
}; };

View file

@ -7,7 +7,7 @@
#include "common/common_types.h" #include "common/common_types.h"
namespace Pica { namespace Pica {
namespace VertexShader { namespace Shader {
struct OutputVertex; struct OutputVertex;
} }
} }
@ -24,9 +24,9 @@ public:
virtual void Reset() = 0; virtual void Reset() = 0;
/// Queues the primitive formed by the given vertices for rendering /// Queues the primitive formed by the given vertices for rendering
virtual void AddTriangle(const Pica::VertexShader::OutputVertex& v0, virtual void AddTriangle(const Pica::Shader::OutputVertex& v0,
const Pica::VertexShader::OutputVertex& v1, const Pica::Shader::OutputVertex& v1,
const Pica::VertexShader::OutputVertex& v2) = 0; const Pica::Shader::OutputVertex& v2) = 0;
/// Draw the current batch of triangles /// Draw the current batch of triangles
virtual void DrawTriangles() = 0; virtual void DrawTriangles() = 0;

View file

@ -4,7 +4,7 @@
#include "pica.h" #include "pica.h"
#include "primitive_assembly.h" #include "primitive_assembly.h"
#include "vertex_shader.h" #include "shader_interpreter.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "video_core/debug_utils/debug_utils.h" #include "video_core/debug_utils/debug_utils.h"
@ -56,7 +56,7 @@ void PrimitiveAssembler<VertexType>::SubmitVertex(VertexType& vtx, TriangleHandl
// explicitly instantiate use cases // explicitly instantiate use cases
template template
struct PrimitiveAssembler<VertexShader::OutputVertex>; struct PrimitiveAssembler<Shader::OutputVertex>;
template template
struct PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex>; struct PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex>;

View file

@ -8,7 +8,7 @@
#include "video_core/pica.h" #include "video_core/pica.h"
#include "video_core/vertex_shader.h" #include "video_core/shader_interpreter.h"
namespace Pica { namespace Pica {

View file

@ -16,7 +16,7 @@
#include "math.h" #include "math.h"
#include "pica.h" #include "pica.h"
#include "rasterizer.h" #include "rasterizer.h"
#include "vertex_shader.h" #include "shader_interpreter.h"
#include "video_core/utils.h" #include "video_core/utils.h"
namespace Pica { namespace Pica {
@ -272,9 +272,9 @@ static Common::Profiling::TimingCategory rasterization_category("Rasterization")
* Helper function for ProcessTriangle with the "reversed" flag to allow for implementing * Helper function for ProcessTriangle with the "reversed" flag to allow for implementing
* culling via recursion. * culling via recursion.
*/ */
static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0, static void ProcessTriangleInternal(const Shader::OutputVertex& v0,
const VertexShader::OutputVertex& v1, const Shader::OutputVertex& v1,
const VertexShader::OutputVertex& v2, const Shader::OutputVertex& v2,
bool reversed = false) bool reversed = false)
{ {
const auto& regs = g_state.regs; const auto& regs = g_state.regs;
@ -1107,9 +1107,9 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
} }
} }
void ProcessTriangle(const VertexShader::OutputVertex& v0, void ProcessTriangle(const Shader::OutputVertex& v0,
const VertexShader::OutputVertex& v1, const Shader::OutputVertex& v1,
const VertexShader::OutputVertex& v2) { const Shader::OutputVertex& v2) {
ProcessTriangleInternal(v0, v1, v2); ProcessTriangleInternal(v0, v1, v2);
} }

View file

@ -6,15 +6,15 @@
namespace Pica { namespace Pica {
namespace VertexShader { namespace Shader {
struct OutputVertex; struct OutputVertex;
} }
namespace Rasterizer { namespace Rasterizer {
void ProcessTriangle(const VertexShader::OutputVertex& v0, void ProcessTriangle(const Shader::OutputVertex& v0,
const VertexShader::OutputVertex& v1, const Shader::OutputVertex& v1,
const VertexShader::OutputVertex& v2); const Shader::OutputVertex& v2);
} // namespace Rasterizer } // namespace Rasterizer

View file

@ -202,9 +202,9 @@ void RasterizerOpenGL::Reset() {
res_cache.FullFlush(); res_cache.FullFlush();
} }
void RasterizerOpenGL::AddTriangle(const Pica::VertexShader::OutputVertex& v0, void RasterizerOpenGL::AddTriangle(const Pica::Shader::OutputVertex& v0,
const Pica::VertexShader::OutputVertex& v1, const Pica::Shader::OutputVertex& v1,
const Pica::VertexShader::OutputVertex& v2) { const Pica::Shader::OutputVertex& v2) {
vertex_batch.push_back(HardwareVertex(v0)); vertex_batch.push_back(HardwareVertex(v0));
vertex_batch.push_back(HardwareVertex(v1)); vertex_batch.push_back(HardwareVertex(v1));
vertex_batch.push_back(HardwareVertex(v2)); vertex_batch.push_back(HardwareVertex(v2));

View file

@ -9,7 +9,7 @@
#include "common/common_types.h" #include "common/common_types.h"
#include "video_core/hwrasterizer_base.h" #include "video_core/hwrasterizer_base.h"
#include "video_core/vertex_shader.h" #include "video_core/shader_interpreter.h"
#include "gl_state.h" #include "gl_state.h"
#include "gl_rasterizer_cache.h" #include "gl_rasterizer_cache.h"
@ -27,9 +27,9 @@ public:
void Reset() override; void Reset() override;
/// Queues the primitive formed by the given vertices for rendering /// Queues the primitive formed by the given vertices for rendering
void AddTriangle(const Pica::VertexShader::OutputVertex& v0, void AddTriangle(const Pica::Shader::OutputVertex& v0,
const Pica::VertexShader::OutputVertex& v1, const Pica::Shader::OutputVertex& v1,
const Pica::VertexShader::OutputVertex& v2) override; const Pica::Shader::OutputVertex& v2) override;
/// Draw the current batch of triangles /// Draw the current batch of triangles
void DrawTriangles() override; void DrawTriangles() override;
@ -82,7 +82,7 @@ private:
/// Structure that the hardware rendered vertices are composed of /// Structure that the hardware rendered vertices are composed of
struct HardwareVertex { struct HardwareVertex {
HardwareVertex(const Pica::VertexShader::OutputVertex& v) { HardwareVertex(const Pica::Shader::OutputVertex& v) {
position[0] = v.pos.x.ToFloat32(); position[0] = v.pos.x.ToFloat32();
position[1] = v.pos.y.ToFloat32(); position[1] = v.pos.y.ToFloat32();
position[2] = v.pos.z.ToFloat32(); position[2] = v.pos.z.ToFloat32();

View file

@ -12,7 +12,7 @@
#include "common/profiler.h" #include "common/profiler.h"
#include "pica.h" #include "pica.h"
#include "vertex_shader.h" #include "shader_interpreter.h"
#include "debug_utils/debug_utils.h" #include "debug_utils/debug_utils.h"
using nihstro::OpCode; using nihstro::OpCode;
@ -23,9 +23,9 @@ using nihstro::SwizzlePattern;
namespace Pica { namespace Pica {
namespace VertexShader { namespace Shader {
struct VertexShaderState { struct ShaderState {
u32 program_counter; u32 program_counter;
const float24* input_register_table[16]; const float24* input_register_table[16];
@ -60,7 +60,7 @@ struct VertexShaderState {
} debug; } debug;
}; };
static void ProcessShaderCode(VertexShaderState& state) { static void ProcessShaderCode(ShaderState& state) {
const auto& uniforms = g_state.vs.uniforms; const auto& uniforms = g_state.vs.uniforms;
const auto& swizzle_data = g_state.vs.swizzle_data; const auto& swizzle_data = g_state.vs.swizzle_data;
const auto& program_code = g_state.vs.program_code; const auto& program_code = g_state.vs.program_code;
@ -90,7 +90,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
const Instruction instr = { program_code[state.program_counter] }; const Instruction instr = { program_code[state.program_counter] };
const SwizzlePattern swizzle = { swizzle_data[instr.common.operand_desc_id] }; const SwizzlePattern swizzle = { swizzle_data[instr.common.operand_desc_id] };
static auto call = [](VertexShaderState& state, u32 offset, u32 num_instructions, static auto call = [](ShaderState& state, u32 offset, u32 num_instructions,
u32 return_offset, u8 repeat_count, u8 loop_increment) { u32 return_offset, u8 repeat_count, u8 loop_increment) {
state.program_counter = offset - 1; // -1 to make sure when incrementing the PC we end up at the correct offset state.program_counter = offset - 1; // -1 to make sure when incrementing the PC we end up at the correct offset
ASSERT(state.call_stack.size() < state.call_stack.capacity()); ASSERT(state.call_stack.size() < state.call_stack.capacity());
@ -413,7 +413,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
default: default:
{ {
static auto evaluate_condition = [](const VertexShaderState& state, bool refx, bool refy, Instruction::FlowControlType flow_control) { static auto evaluate_condition = [](const ShaderState& state, bool refx, bool refy, Instruction::FlowControlType flow_control) {
bool results[2] = { refx == state.conditional_code[0], bool results[2] = { refx == state.conditional_code[0],
refy == state.conditional_code[1] }; refy == state.conditional_code[1] };
@ -547,7 +547,7 @@ static Common::Profiling::TimingCategory shader_category("Vertex Shader");
OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup) { OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup) {
Common::Profiling::ScopeTimer timer(shader_category); Common::Profiling::ScopeTimer timer(shader_category);
VertexShaderState state; ShaderState state;
state.program_counter = config.main_offset; state.program_counter = config.main_offset;
state.debug.max_offset = 0; state.debug.max_offset = 0;

View file

@ -12,7 +12,7 @@
namespace Pica { namespace Pica {
namespace VertexShader { namespace Shader {
struct InputVertex { struct InputVertex {
Math::Vec4<float24> attr[16]; Math::Vec4<float24> attr[16];
@ -70,4 +70,3 @@ OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs:
} // namespace } // namespace
} // namespace } // namespace