mirror of
https://github.com/PabloMK7/citra.git
synced 2024-12-29 11:06:12 +00:00
gl_rasterizer: add clipping plane z<=0 defined in PICA
This commit is contained in:
parent
46d1ca768d
commit
1eca380886
|
@ -28,6 +28,9 @@ MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(100, 100, 255));
|
|||
MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100));
|
||||
|
||||
RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
|
||||
// Clipping plane 0 is always enabled for PICA fixed clip plane z <= 0
|
||||
state.clip_distance[0] = true;
|
||||
|
||||
// Create sampler objects
|
||||
for (size_t i = 0; i < texture_samplers.size(); ++i) {
|
||||
texture_samplers[i].Create();
|
||||
|
|
|
@ -1196,6 +1196,8 @@ void main() {
|
|||
normquat = vert_normquat;
|
||||
view = vert_view;
|
||||
gl_Position = vec4(vert_position.x, vert_position.y, -vert_position.z, vert_position.w);
|
||||
gl_ClipDistance[0] = -vert_position.z; // fixed PICA clipping plane z <= 0
|
||||
// TODO (wwylele): calculate gl_ClipDistance[1] from user-defined clipping plane
|
||||
}
|
||||
)";
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ OpenGLState::OpenGLState() {
|
|||
draw.vertex_buffer = 0;
|
||||
draw.uniform_buffer = 0;
|
||||
draw.shader_program = 0;
|
||||
|
||||
clip_distance = {};
|
||||
}
|
||||
|
||||
void OpenGLState::Apply() const {
|
||||
|
@ -261,6 +263,17 @@ void OpenGLState::Apply() const {
|
|||
glUseProgram(draw.shader_program);
|
||||
}
|
||||
|
||||
// Clip distance
|
||||
for (size_t i = 0; i < clip_distance.size(); ++i) {
|
||||
if (clip_distance[i] != cur_state.clip_distance[i]) {
|
||||
if (clip_distance[i]) {
|
||||
glEnable(GL_CLIP_DISTANCE0 + i);
|
||||
} else {
|
||||
glDisable(GL_CLIP_DISTANCE0 + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_state = *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <glad/glad.h>
|
||||
|
||||
namespace TextureUnits {
|
||||
|
@ -123,6 +124,8 @@ public:
|
|||
GLuint shader_program; // GL_CURRENT_PROGRAM
|
||||
} draw;
|
||||
|
||||
std::array<bool, 2> clip_distance; // GL_CLIP_DISTANCE
|
||||
|
||||
OpenGLState();
|
||||
|
||||
/// Get the currently active OpenGL state
|
||||
|
|
Loading…
Reference in a new issue