diff --git a/src/xenia/gpu/gl4/circular_buffer.cc b/src/xenia/gpu/gl4/circular_buffer.cc index e33677406..a2554f9fb 100644 --- a/src/xenia/gpu/gl4/circular_buffer.cc +++ b/src/xenia/gpu/gl4/circular_buffer.cc @@ -47,7 +47,7 @@ bool CircularBuffer::Initialize() { if (FLAGS_vendor_gl_extensions && GLEW_NV_shader_buffer_load) { // To use this bindlessly we must make it resident. - glMakeNamedBufferResidentNV(buffer_, GL_WRITE_ONLY); + glMakeNamedBufferResidentNV(buffer_, GL_READ_ONLY); glGetNamedBufferParameterui64vNV(buffer_, GL_BUFFER_GPU_ADDRESS_NV, &gpu_base_); } @@ -90,11 +90,16 @@ CircularBuffer::Allocation CircularBuffer::Acquire(size_t length) { return allocation; } +void CircularBuffer::Discard(Allocation allocation) { + write_head_ -= allocation.aligned_length; +} + void CircularBuffer::Commit(Allocation allocation) { uintptr_t start = allocation.gpu_ptr - gpu_base_; uintptr_t end = start + allocation.aligned_length; dirty_start_ = std::min(dirty_start_, start); dirty_end_ = std::max(dirty_end_, end); + assert_true(dirty_end_ <= capacity_); } void CircularBuffer::Flush() { diff --git a/src/xenia/gpu/gl4/circular_buffer.h b/src/xenia/gpu/gl4/circular_buffer.h index 2db1d639c..d7288d5a8 100644 --- a/src/xenia/gpu/gl4/circular_buffer.h +++ b/src/xenia/gpu/gl4/circular_buffer.h @@ -38,6 +38,7 @@ class CircularBuffer { bool CanAcquire(size_t length); Allocation Acquire(size_t length); + void Discard(Allocation allocation); void Commit(Allocation allocation); void Flush(); diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc index 460f6df29..750079ae5 100644 --- a/src/xenia/gpu/gl4/command_processor.cc +++ b/src/xenia/gpu/gl4/command_processor.cc @@ -163,7 +163,6 @@ void CommandProcessor::WorkerMain() { } bool CommandProcessor::SetupGL() { - glViewport(0, 0, 1280, 720); // Circular buffer holding scratch vertex/index data. if (!scratch_buffer_.Initialize()) { @@ -1580,6 +1579,8 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRenderTargets( // TODO(benvanik): can we do this all named? // TODO(benvanik): do we want this on READ too? glBindFramebuffer(GL_DRAW_FRAMEBUFFER, cached_framebuffer->framebuffer); + + glViewport(0, 0, 1280, 720); } return UpdateStatus::kMismatch; diff --git a/src/xenia/gpu/gl4/gl4_shader_translator.cc b/src/xenia/gpu/gl4/gl4_shader_translator.cc index 8ceab5547..e314191ea 100644 --- a/src/xenia/gpu/gl4/gl4_shader_translator.cc +++ b/src/xenia/gpu/gl4/gl4_shader_translator.cc @@ -936,7 +936,8 @@ bool GL4ShaderTranslator::TranslateALU_RECIP_IEEE(const instr_alu_t& alu) { return true; } -bool GL4ShaderTranslator::TranslateALU_RECIPSQ_IEEE(const ucode::instr_alu_t& alu) { +bool GL4ShaderTranslator::TranslateALU_RECIPSQ_IEEE( + const ucode::instr_alu_t& alu) { AppendDestReg(alu.scalar_dest, alu.scalar_write_mask, alu.export_data); Append(" = "); if (alu.scalar_clamp) { @@ -1298,8 +1299,7 @@ bool GL4ShaderTranslator::TranslateALU(const instr_alu_t* alu, int sync) { } else { Append("\t \tOP(%u)\t", alu->scalar_opc); } - PrintDstReg(alu->scalar_dest, alu->scalar_write_mask, - alu->export_data); + PrintDstReg(alu->scalar_dest, alu->scalar_write_mask, alu->export_data); Append(" = "); if (is.num_srcs == 2) { // ADD_CONST_0 dest, [const], [reg] diff --git a/src/xenia/gpu/shader.cc b/src/xenia/gpu/shader.cc index a3812b814..c79d51727 100644 --- a/src/xenia/gpu/shader.cc +++ b/src/xenia/gpu/shader.cc @@ -215,6 +215,7 @@ void Shader::GatherVertexFetch(const instr_fetch_vtx_t* vtx) { desc.stride_words = vtx->stride; el = &desc.elements[desc.element_count++]; } + ++inputs.total_elements_count; el->vtx_fetch = *vtx; el->format = static_cast(vtx->format); diff --git a/src/xenia/gpu/shader.h b/src/xenia/gpu/shader.h index e5383b6dc..5983b851d 100644 --- a/src/xenia/gpu/shader.h +++ b/src/xenia/gpu/shader.h @@ -51,6 +51,7 @@ class Shader { }; struct BufferInputs { uint32_t count; + uint32_t total_elements_count; BufferDesc descs[32]; }; const BufferInputs& buffer_inputs() { return buffer_inputs_; }