mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-26 05:21:21 -08:00
gl_rasterizer: Fix check for if a shader stage is enabled.
This commit is contained in:
parent
c4015cd93a
commit
8aeff9cf8e
@ -398,27 +398,6 @@ u32 Maxwell3D::GetRegisterValue(u32 method) const {
|
|||||||
return regs.reg_array[method];
|
return regs.reg_array[method];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Maxwell3D::IsShaderStageEnabled(Regs::ShaderStage stage) const {
|
|
||||||
// The Vertex stage is always enabled.
|
|
||||||
if (stage == Regs::ShaderStage::Vertex)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
switch (stage) {
|
|
||||||
case Regs::ShaderStage::TesselationControl:
|
|
||||||
return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::TesselationControl)]
|
|
||||||
.enable != 0;
|
|
||||||
case Regs::ShaderStage::TesselationEval:
|
|
||||||
return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::TesselationEval)]
|
|
||||||
.enable != 0;
|
|
||||||
case Regs::ShaderStage::Geometry:
|
|
||||||
return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::Geometry)].enable != 0;
|
|
||||||
case Regs::ShaderStage::Fragment:
|
|
||||||
return regs.shader_config[static_cast<size_t>(Regs::ShaderProgram::Fragment)].enable != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Maxwell3D::ProcessClearBuffers() {
|
void Maxwell3D::ProcessClearBuffers() {
|
||||||
ASSERT(regs.clear_buffers.R == regs.clear_buffers.G &&
|
ASSERT(regs.clear_buffers.R == regs.clear_buffers.G &&
|
||||||
regs.clear_buffers.R == regs.clear_buffers.B &&
|
regs.clear_buffers.R == regs.clear_buffers.B &&
|
||||||
|
@ -379,6 +379,14 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool IsShaderConfigEnabled(size_t index) const {
|
||||||
|
// The VertexB is always enabled.
|
||||||
|
if (index == static_cast<size_t>(Regs::ShaderProgram::VertexB)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return shader_config[index].enable != 0;
|
||||||
|
}
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
INSERT_PADDING_WORDS(0x45);
|
INSERT_PADDING_WORDS(0x45);
|
||||||
@ -780,9 +788,6 @@ public:
|
|||||||
/// Returns the texture information for a specific texture in a specific shader stage.
|
/// Returns the texture information for a specific texture in a specific shader stage.
|
||||||
Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, size_t offset) const;
|
Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, size_t offset) const;
|
||||||
|
|
||||||
/// Returns whether the specified shader stage is enabled or not.
|
|
||||||
bool IsShaderStageEnabled(Regs::ShaderStage stage) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<u32, std::vector<u32>> uploaded_macros;
|
std::unordered_map<u32, std::vector<u32>> uploaded_macros;
|
||||||
|
|
||||||
|
@ -216,15 +216,13 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset) {
|
|||||||
auto& shader_config = gpu.regs.shader_config[index];
|
auto& shader_config = gpu.regs.shader_config[index];
|
||||||
const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)};
|
const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)};
|
||||||
|
|
||||||
const size_t stage{index == 0 ? 0 : index - 1}; // Stage indices are 0 - 5
|
|
||||||
|
|
||||||
const bool is_enabled = gpu.IsShaderStageEnabled(static_cast<Maxwell::ShaderStage>(stage));
|
|
||||||
|
|
||||||
// Skip stages that are not enabled
|
// Skip stages that are not enabled
|
||||||
if (!is_enabled) {
|
if (!gpu.regs.IsShaderConfigEnabled(index)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const size_t stage{index == 0 ? 0 : index - 1}; // Stage indices are 0 - 5
|
||||||
|
|
||||||
GLShader::MaxwellUniformData ubo{};
|
GLShader::MaxwellUniformData ubo{};
|
||||||
ubo.SetFromRegs(gpu.state.shader_stages[stage]);
|
ubo.SetFromRegs(gpu.state.shader_stages[stage]);
|
||||||
std::memcpy(buffer_ptr, &ubo, sizeof(ubo));
|
std::memcpy(buffer_ptr, &ubo, sizeof(ubo));
|
||||||
@ -628,9 +626,6 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr
|
|||||||
auto& gpu = Core::System::GetInstance().GPU();
|
auto& gpu = Core::System::GetInstance().GPU();
|
||||||
auto& maxwell3d = gpu.Get3DEngine();
|
auto& maxwell3d = gpu.Get3DEngine();
|
||||||
|
|
||||||
ASSERT_MSG(maxwell3d.IsShaderStageEnabled(stage),
|
|
||||||
"Attempted to upload constbuffer of disabled shader stage");
|
|
||||||
|
|
||||||
// Reset all buffer draw state for this stage.
|
// Reset all buffer draw state for this stage.
|
||||||
for (auto& buffer : state.draw.const_buffers[static_cast<size_t>(stage)]) {
|
for (auto& buffer : state.draw.const_buffers[static_cast<size_t>(stage)]) {
|
||||||
buffer.bindpoint = 0;
|
buffer.bindpoint = 0;
|
||||||
@ -697,9 +692,6 @@ u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, GLuint program,
|
|||||||
auto& gpu = Core::System::GetInstance().GPU();
|
auto& gpu = Core::System::GetInstance().GPU();
|
||||||
auto& maxwell3d = gpu.Get3DEngine();
|
auto& maxwell3d = gpu.Get3DEngine();
|
||||||
|
|
||||||
ASSERT_MSG(maxwell3d.IsShaderStageEnabled(stage),
|
|
||||||
"Attempted to upload textures of disabled shader stage");
|
|
||||||
|
|
||||||
ASSERT_MSG(current_unit + entries.size() <= std::size(state.texture_units),
|
ASSERT_MSG(current_unit + entries.size() <= std::size(state.texture_units),
|
||||||
"Exceeded the number of active textures.");
|
"Exceeded the number of active textures.");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user