1
0
Fork 0
forked from suyu/suyu

gl_rasterizer: Implement primitive restart.

This commit is contained in:
bunnei 2018-10-25 19:04:13 -04:00
parent d278f25bda
commit 58444a0376
5 changed files with 40 additions and 1 deletions

View file

@ -751,7 +751,14 @@ public:
}; };
} draw; } draw;
INSERT_PADDING_WORDS(0x6B); INSERT_PADDING_WORDS(0xA);
struct {
u32 enabled;
u32 index;
} primitive_restart;
INSERT_PADDING_WORDS(0x5F);
struct { struct {
u32 start_addr_high; u32 start_addr_high;
@ -1082,6 +1089,7 @@ ASSERT_REG_POSITION(stencil_back_func_func, 0x569);
ASSERT_REG_POSITION(point_coord_replace, 0x581); ASSERT_REG_POSITION(point_coord_replace, 0x581);
ASSERT_REG_POSITION(code_address, 0x582); ASSERT_REG_POSITION(code_address, 0x582);
ASSERT_REG_POSITION(draw, 0x585); ASSERT_REG_POSITION(draw, 0x585);
ASSERT_REG_POSITION(primitive_restart, 0x591);
ASSERT_REG_POSITION(index_array, 0x5F2); ASSERT_REG_POSITION(index_array, 0x5F2);
ASSERT_REG_POSITION(instanced_arrays, 0x620); ASSERT_REG_POSITION(instanced_arrays, 0x620);
ASSERT_REG_POSITION(cull, 0x646); ASSERT_REG_POSITION(cull, 0x646);

View file

@ -570,6 +570,7 @@ void RasterizerOpenGL::DrawArrays() {
SyncBlendState(); SyncBlendState();
SyncLogicOpState(); SyncLogicOpState();
SyncCullMode(); SyncCullMode();
SyncPrimitiveRestart();
SyncDepthRange(); SyncDepthRange();
SyncScissorTest(); SyncScissorTest();
// Alpha Testing is synced on shaders. // Alpha Testing is synced on shaders.
@ -924,6 +925,13 @@ void RasterizerOpenGL::SyncCullMode() {
} }
} }
void RasterizerOpenGL::SyncPrimitiveRestart() {
const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs;
state.primitive_restart.enabled = regs.primitive_restart.enabled;
state.primitive_restart.index = regs.primitive_restart.index;
}
void RasterizerOpenGL::SyncDepthRange() { void RasterizerOpenGL::SyncDepthRange() {
const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs;

View file

@ -144,6 +144,9 @@ private:
/// Syncs the cull mode to match the guest state /// Syncs the cull mode to match the guest state
void SyncCullMode(); void SyncCullMode();
/// Syncs the primitve restart to match the guest state
void SyncPrimitiveRestart();
/// Syncs the depth range to match the guest state /// Syncs the depth range to match the guest state
void SyncDepthRange(); void SyncDepthRange();

View file

@ -24,6 +24,9 @@ OpenGLState::OpenGLState() {
depth.depth_range_near = 0.0f; depth.depth_range_near = 0.0f;
depth.depth_range_far = 1.0f; depth.depth_range_far = 1.0f;
primitive_restart.enabled = false;
primitive_restart.index = 0;
color_mask.red_enabled = GL_TRUE; color_mask.red_enabled = GL_TRUE;
color_mask.green_enabled = GL_TRUE; color_mask.green_enabled = GL_TRUE;
color_mask.blue_enabled = GL_TRUE; color_mask.blue_enabled = GL_TRUE;
@ -127,6 +130,18 @@ void OpenGLState::Apply() const {
glDepthRange(depth.depth_range_near, depth.depth_range_far); glDepthRange(depth.depth_range_near, depth.depth_range_far);
} }
// Primitive restart
if (primitive_restart.enabled != cur_state.primitive_restart.enabled) {
if (primitive_restart.enabled) {
glEnable(GL_PRIMITIVE_RESTART);
} else {
glDisable(GL_PRIMITIVE_RESTART);
}
}
if (primitive_restart.index != cur_state.primitive_restart.index) {
glPrimitiveRestartIndex(primitive_restart.index);
}
// Color mask // Color mask
if (color_mask.red_enabled != cur_state.color_mask.red_enabled || if (color_mask.red_enabled != cur_state.color_mask.red_enabled ||
color_mask.green_enabled != cur_state.color_mask.green_enabled || color_mask.green_enabled != cur_state.color_mask.green_enabled ||

View file

@ -49,6 +49,11 @@ public:
GLfloat depth_range_far; // GL_DEPTH_RANGE GLfloat depth_range_far; // GL_DEPTH_RANGE
} depth; } depth;
struct {
bool enabled;
GLuint index;
} primitive_restart; // GL_PRIMITIVE_RESTART
struct { struct {
GLboolean red_enabled; GLboolean red_enabled;
GLboolean green_enabled; GLboolean green_enabled;