2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Pica: Add primitive assembly stage.

This commit is contained in:
Tony Wasserka 2014-07-27 14:58:30 +02:00
parent c526512619
commit 9a76a2d061
7 changed files with 95 additions and 2 deletions

View file

@ -1,4 +1,5 @@
set(SRCS command_processor.cpp
primitive_assembly.cpp
utils.cpp
vertex_shader.cpp
video_core.cpp
@ -6,6 +7,7 @@ set(SRCS command_processor.cpp
set(HEADERS command_processor.h
math.h
primitive_assembly.h
utils.h
video_core.h
renderer_base.h

View file

@ -5,6 +5,7 @@
#include "command_processor.h"
#include "math.h"
#include "pica.h"
#include "primitive_assembly.h"
#include "vertex_shader.h"
@ -100,7 +101,7 @@ static inline void WritePicaReg(u32 id, u32 value) {
// TODO: Add processed vertex to vertex cache!
}
// TODO: Submit vertex to primitive assembly
PrimitiveAssembly::SubmitVertex(output);
}
break;
}

View file

@ -221,7 +221,18 @@ struct Regs {
u32 trigger_draw;
u32 trigger_draw_indexed;
INSERT_PADDING_WORDS(0x8a);
INSERT_PADDING_WORDS(0x2e);
enum class TriangleTopology : u32 {
List = 0,
Strip = 1,
Fan = 2,
ListIndexed = 3, // TODO: No idea if this is correct
};
BitField<8, 2, TriangleTopology> triangle_topology;
INSERT_PADDING_WORDS(0x5b);
// Offset to shader program entry point (in words)
BitField<0, 16, u32> vs_main_offset;
@ -334,6 +345,7 @@ struct Regs {
ADD_FIELD(num_vertices);
ADD_FIELD(trigger_draw);
ADD_FIELD(trigger_draw_indexed);
ADD_FIELD(triangle_topology);
ADD_FIELD(vs_main_offset);
ADD_FIELD(vs_input_register_map);
ADD_FIELD(vs_uniform_setup);
@ -386,6 +398,7 @@ ASSERT_REG_POSITION(index_array, 0x227);
ASSERT_REG_POSITION(num_vertices, 0x228);
ASSERT_REG_POSITION(trigger_draw, 0x22e);
ASSERT_REG_POSITION(trigger_draw_indexed, 0x22f);
ASSERT_REG_POSITION(triangle_topology, 0x25e);
ASSERT_REG_POSITION(vs_main_offset, 0x2ba);
ASSERT_REG_POSITION(vs_input_register_map, 0x2bb);
ASSERT_REG_POSITION(vs_uniform_setup, 0x2c0);

View file

@ -0,0 +1,52 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "pica.h"
#include "primitive_assembly.h"
#include "vertex_shader.h"
namespace Pica {
namespace PrimitiveAssembly {
static OutputVertex buffer[2];
static int buffer_index = 0; // TODO: reset this on emulation restart
void SubmitVertex(OutputVertex& vtx)
{
switch (registers.triangle_topology) {
case Regs::TriangleTopology::List:
case Regs::TriangleTopology::ListIndexed:
if (buffer_index < 2) {
buffer[buffer_index++] = vtx;
} else {
buffer_index = 0;
// TODO
// Clipper::ProcessTriangle(buffer[0], buffer[1], vtx);
}
break;
case Regs::TriangleTopology::Fan:
if (buffer_index == 2) {
buffer_index = 0;
// TODO
// Clipper::ProcessTriangle(buffer[0], buffer[1], vtx);
buffer[1] = vtx;
} else {
buffer[buffer_index++] = vtx;
}
break;
default:
ERROR_LOG(GPU, "Unknown triangle mode %x:", (int)registers.triangle_topology.Value());
break;
}
}
} // namespace
} // namespace

View file

@ -0,0 +1,21 @@
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
namespace Pica {
namespace VertexShader {
struct OutputVertex;
}
namespace PrimitiveAssembly {
using VertexShader::OutputVertex;
void SubmitVertex(OutputVertex& vtx);
} // namespace
} // namespace

View file

@ -21,6 +21,7 @@
<ItemGroup>
<ClCompile Include="renderer_opengl\renderer_opengl.cpp" />
<ClCompile Include="command_processor.cpp" />
<ClCompile Include="primitive_assembly.cpp" />
<ClCompile Include="utils.cpp" />
<ClCompile Include="vertex_shader.cpp" />
<ClCompile Include="video_core.cpp" />
@ -30,6 +31,7 @@
<ClInclude Include="gpu_debugger.h" />
<ClInclude Include="math.h" />
<ClInclude Include="pica.h" />
<ClInclude Include="primitive_assembly.h" />
<ClInclude Include="renderer_base.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="vertex_shader.h" />

View file

@ -10,6 +10,7 @@
<Filter>renderer_opengl</Filter>
</ClCompile>
<ClCompile Include="command_processor.cpp" />
<ClCompile Include="primitive_assembly.cpp" />
<ClCompile Include="utils.cpp" />
<ClCompile Include="vertex_shader.cpp" />
<ClCompile Include="video_core.cpp" />
@ -22,6 +23,7 @@
<ClInclude Include="gpu_debugger.h" />
<ClInclude Include="math.h" />
<ClInclude Include="pica.h" />
<ClInclude Include="primitive_assembly.h" />
<ClInclude Include="renderer_base.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="vertex_shader.h" />