|
|
@ -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);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|