mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-28 04:00:05 +00:00
gl_state: Don't track constant buffer mappings.
This commit is contained in:
parent
6ff7906ddc
commit
0af7e93763
@ -628,28 +628,17 @@ std::tuple<u8*, GLintptr, u32> RasterizerOpenGL::SetupConstBuffers(
|
|||||||
const auto& gpu = Core::System::GetInstance().GPU();
|
const auto& gpu = Core::System::GetInstance().GPU();
|
||||||
const auto& maxwell3d = gpu.Maxwell3D();
|
const auto& maxwell3d = gpu.Maxwell3D();
|
||||||
|
|
||||||
// Reset all buffer draw state for this stage.
|
|
||||||
for (auto& buffer : state.draw.const_buffers[static_cast<size_t>(stage)]) {
|
|
||||||
buffer.bindpoint = 0;
|
|
||||||
buffer.enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Upload only the enabled buffers from the 16 constbuffers of each shader stage
|
// Upload only the enabled buffers from the 16 constbuffers of each shader stage
|
||||||
const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<size_t>(stage)];
|
const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<size_t>(stage)];
|
||||||
|
|
||||||
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
||||||
const auto& used_buffer = entries[bindpoint];
|
const auto& used_buffer = entries[bindpoint];
|
||||||
const auto& buffer = shader_stage.const_buffers[used_buffer.GetIndex()];
|
const auto& buffer = shader_stage.const_buffers[used_buffer.GetIndex()];
|
||||||
auto& buffer_draw_state =
|
|
||||||
state.draw.const_buffers[static_cast<size_t>(stage)][used_buffer.GetIndex()];
|
|
||||||
|
|
||||||
if (!buffer.enabled) {
|
if (!buffer.enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_draw_state.enabled = true;
|
|
||||||
buffer_draw_state.bindpoint = current_bindpoint + bindpoint;
|
|
||||||
|
|
||||||
boost::optional<VAddr> addr = gpu.memory_manager->GpuToCpuAddress(buffer.address);
|
boost::optional<VAddr> addr = gpu.memory_manager->GpuToCpuAddress(buffer.address);
|
||||||
|
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
@ -676,9 +665,8 @@ std::tuple<u8*, GLintptr, u32> RasterizerOpenGL::SetupConstBuffers(
|
|||||||
std::tie(buffer_ptr, buffer_offset) =
|
std::tie(buffer_ptr, buffer_offset) =
|
||||||
AlignBuffer(buffer_ptr, buffer_offset, static_cast<size_t>(uniform_buffer_alignment));
|
AlignBuffer(buffer_ptr, buffer_offset, static_cast<size_t>(uniform_buffer_alignment));
|
||||||
|
|
||||||
buffer_draw_state.size = size;
|
glBindBufferRange(GL_UNIFORM_BUFFER, current_bindpoint + bindpoint,
|
||||||
buffer_draw_state.offset = buffer_offset;
|
stream_buffer.GetHandle(), buffer_offset, size);
|
||||||
buffer_draw_state.ssbo = stream_buffer.GetHandle();
|
|
||||||
|
|
||||||
Memory::ReadBlock(*addr, buffer_ptr, size);
|
Memory::ReadBlock(*addr, buffer_ptr, size);
|
||||||
buffer_ptr += size;
|
buffer_ptr += size;
|
||||||
@ -689,7 +677,7 @@ std::tuple<u8*, GLintptr, u32> RasterizerOpenGL::SetupConstBuffers(
|
|||||||
const GLuint index =
|
const GLuint index =
|
||||||
glGetProgramResourceIndex(program, GL_UNIFORM_BLOCK, buffer_name.c_str());
|
glGetProgramResourceIndex(program, GL_UNIFORM_BLOCK, buffer_name.c_str());
|
||||||
if (index != GL_INVALID_INDEX) {
|
if (index != GL_INVALID_INDEX) {
|
||||||
glUniformBlockBinding(program, index, buffer_draw_state.bindpoint);
|
glUniformBlockBinding(program, index, current_bindpoint + bindpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,24 +203,6 @@ void OpenGLState::Apply() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constbuffers
|
|
||||||
for (std::size_t stage = 0; stage < draw.const_buffers.size(); ++stage) {
|
|
||||||
for (std::size_t buffer_id = 0; buffer_id < draw.const_buffers[stage].size(); ++buffer_id) {
|
|
||||||
const auto& current = cur_state.draw.const_buffers[stage][buffer_id];
|
|
||||||
const auto& new_state = draw.const_buffers[stage][buffer_id];
|
|
||||||
|
|
||||||
if (std::tie(current.enabled, current.bindpoint, current.ssbo, current.size,
|
|
||||||
current.offset) != std::tie(new_state.enabled, new_state.bindpoint,
|
|
||||||
new_state.ssbo, new_state.size,
|
|
||||||
new_state.offset)) {
|
|
||||||
if (new_state.enabled) {
|
|
||||||
glBindBufferRange(GL_UNIFORM_BUFFER, new_state.bindpoint, new_state.ssbo,
|
|
||||||
new_state.offset, new_state.size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Framebuffer
|
// Framebuffer
|
||||||
if (draw.read_framebuffer != cur_state.draw.read_framebuffer) {
|
if (draw.read_framebuffer != cur_state.draw.read_framebuffer) {
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, draw.read_framebuffer);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, draw.read_framebuffer);
|
||||||
|
@ -119,14 +119,6 @@ public:
|
|||||||
GLuint uniform_buffer; // GL_UNIFORM_BUFFER_BINDING
|
GLuint uniform_buffer; // GL_UNIFORM_BUFFER_BINDING
|
||||||
GLuint shader_program; // GL_CURRENT_PROGRAM
|
GLuint shader_program; // GL_CURRENT_PROGRAM
|
||||||
GLuint program_pipeline; // GL_PROGRAM_PIPELINE_BINDING
|
GLuint program_pipeline; // GL_PROGRAM_PIPELINE_BINDING
|
||||||
struct ConstBufferConfig {
|
|
||||||
bool enabled = false;
|
|
||||||
GLuint bindpoint;
|
|
||||||
GLuint ssbo;
|
|
||||||
GLsizeiptr size;
|
|
||||||
GLintptr offset;
|
|
||||||
};
|
|
||||||
std::array<std::array<ConstBufferConfig, Regs::MaxConstBuffers>, 5> const_buffers;
|
|
||||||
} draw;
|
} draw;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user