mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
GLES: Support more clip distances.
Will be used later, for now just the enable/disable logic.
This commit is contained in:
parent
f2beafe769
commit
c08c873462
@ -811,7 +811,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
|
||||
int logicOp = -1;
|
||||
bool logicEnabled = false;
|
||||
#endif
|
||||
bool clipDistance0Enabled = false;
|
||||
bool clipDistanceEnabled[8]{};
|
||||
GLuint blendEqColor = (GLuint)-1;
|
||||
GLuint blendEqAlpha = (GLuint)-1;
|
||||
|
||||
@ -1119,14 +1119,18 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
|
||||
{
|
||||
if (curProgram != c.program.program) {
|
||||
glUseProgram(c.program.program->program);
|
||||
if (c.program.program->use_clip_distance0 != clipDistance0Enabled) {
|
||||
if (c.program.program->use_clip_distance0)
|
||||
glEnable(GL_CLIP_DISTANCE0);
|
||||
else
|
||||
glDisable(GL_CLIP_DISTANCE0);
|
||||
clipDistance0Enabled = c.program.program->use_clip_distance0;
|
||||
}
|
||||
curProgram = c.program.program;
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(clipDistanceEnabled); ++i) {
|
||||
if (c.program.program->use_clip_distance[i] == clipDistanceEnabled[i])
|
||||
continue;
|
||||
|
||||
if (c.program.program->use_clip_distance[i])
|
||||
glEnable(GL_CLIP_DISTANCE0 + (GLenum)i);
|
||||
else
|
||||
glDisable(GL_CLIP_DISTANCE0 + (GLenum)i);
|
||||
clipDistanceEnabled[i] = c.program.program->use_clip_distance[i];
|
||||
}
|
||||
}
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
break;
|
||||
@ -1366,8 +1370,10 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last
|
||||
glDisable(GL_COLOR_LOGIC_OP);
|
||||
}
|
||||
#endif
|
||||
if (clipDistance0Enabled)
|
||||
glDisable(GL_CLIP_DISTANCE0);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(clipDistanceEnabled); ++i) {
|
||||
if (clipDistanceEnabled[i])
|
||||
glDisable(GL_CLIP_DISTANCE0 + (GLenum)i);
|
||||
}
|
||||
if ((colorMask & 15) != 15)
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
CHECK_GL_ERROR_IF_DEBUG();
|
||||
|
@ -91,6 +91,13 @@ public:
|
||||
std::string error;
|
||||
};
|
||||
|
||||
struct GLRProgramFlags {
|
||||
bool supportDualSource : 1;
|
||||
bool useClipDistance0 : 1;
|
||||
bool useClipDistance1 : 1;
|
||||
bool useClipDistance2 : 1;
|
||||
};
|
||||
|
||||
class GLRProgram {
|
||||
public:
|
||||
~GLRProgram() {
|
||||
@ -119,7 +126,7 @@ public:
|
||||
std::vector<Semantic> semantics_;
|
||||
std::vector<UniformLocQuery> queries_;
|
||||
std::vector<Initializer> initialize_;
|
||||
bool use_clip_distance0 = false;
|
||||
bool use_clip_distance[8]{};
|
||||
|
||||
struct UniformInfo {
|
||||
int loc_;
|
||||
@ -427,15 +434,17 @@ public:
|
||||
// not be an active render pass.
|
||||
GLRProgram *CreateProgram(
|
||||
std::vector<GLRShader *> shaders, std::vector<GLRProgram::Semantic> semantics, std::vector<GLRProgram::UniformLocQuery> queries,
|
||||
std::vector<GLRProgram::Initializer> initializers, bool supportDualSource, bool useClipDistance0) {
|
||||
std::vector<GLRProgram::Initializer> initializers, const GLRProgramFlags &flags) {
|
||||
GLRInitStep step{ GLRInitStepType::CREATE_PROGRAM };
|
||||
_assert_(shaders.size() <= ARRAY_SIZE(step.create_program.shaders));
|
||||
step.create_program.program = new GLRProgram();
|
||||
step.create_program.program->semantics_ = semantics;
|
||||
step.create_program.program->queries_ = queries;
|
||||
step.create_program.program->initialize_ = initializers;
|
||||
step.create_program.program->use_clip_distance0 = useClipDistance0;
|
||||
step.create_program.support_dual_source = supportDualSource;
|
||||
step.create_program.program->use_clip_distance[0] = flags.useClipDistance0;
|
||||
step.create_program.program->use_clip_distance[1] = flags.useClipDistance1;
|
||||
step.create_program.program->use_clip_distance[2] = flags.useClipDistance2;
|
||||
step.create_program.support_dual_source = flags.supportDualSource;
|
||||
_assert_msg_(shaders.size() > 0, "Can't create a program with zero shaders");
|
||||
for (size_t i = 0; i < shaders.size(); i++) {
|
||||
step.create_program.shaders[i] = shaders[i];
|
||||
|
@ -1234,7 +1234,8 @@ bool OpenGLPipeline::LinkShaders() {
|
||||
}
|
||||
}
|
||||
|
||||
program_ = render_->CreateProgram(linkShaders, semantics, queries, initialize, false, false);
|
||||
GLRProgramFlags flags{};
|
||||
program_ = render_->CreateProgram(linkShaders, semantics, queries, initialize, flags);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,8 @@ void FramebufferManagerGLES::PackDepthbuffer(VirtualFramebuffer *vfb, int x, int
|
||||
queries.push_back({ &u_depthDownloadTo8, "u_depthTo8" });
|
||||
std::vector<GLRProgram::Initializer> inits;
|
||||
inits.push_back({ &u_depthDownloadTex, 0, TEX_SLOT_PSP_TEXTURE });
|
||||
depthDownloadProgram_ = render->CreateProgram(shaders, semantics, queries, inits, false, false);
|
||||
GLRProgramFlags flags{};
|
||||
depthDownloadProgram_ = render->CreateProgram(shaders, semantics, queries, inits, flags);
|
||||
for (auto iter : shaders) {
|
||||
render->DeleteShader(iter);
|
||||
}
|
||||
|
@ -192,9 +192,13 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs,
|
||||
initialize.push_back({ &u_tess_weights_u, 0, TEX_SLOT_SPLINE_WEIGHTS_U });
|
||||
initialize.push_back({ &u_tess_weights_v, 0, TEX_SLOT_SPLINE_WEIGHTS_V });
|
||||
|
||||
bool useDualSource = (gstate_c.featureFlags & GPU_SUPPORTS_DUALSOURCE_BLEND) != 0;
|
||||
bool useClip0 = VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE);
|
||||
program = render->CreateProgram(shaders, semantics, queries, initialize, useDualSource, useClip0);
|
||||
GLRProgramFlags flags{};
|
||||
flags.supportDualSource = (gstate_c.featureFlags & GPU_SUPPORTS_DUALSOURCE_BLEND) != 0;
|
||||
if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) {
|
||||
flags.useClipDistance0 = true;
|
||||
}
|
||||
|
||||
program = render->CreateProgram(shaders, semantics, queries, initialize, flags);
|
||||
|
||||
// The rest, use the "dirty" mechanism.
|
||||
dirtyUniforms = DIRTY_ALL_UNIFORMS;
|
||||
|
Loading…
Reference in New Issue
Block a user