Misc tweaks.

This commit is contained in:
Ben Vanik 2015-01-04 04:59:26 -08:00
parent 34fb0e4a8a
commit eda38a7428
6 changed files with 14 additions and 5 deletions

View File

@ -47,7 +47,7 @@ bool CircularBuffer::Initialize() {
if (FLAGS_vendor_gl_extensions && GLEW_NV_shader_buffer_load) { if (FLAGS_vendor_gl_extensions && GLEW_NV_shader_buffer_load) {
// To use this bindlessly we must make it resident. // 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, glGetNamedBufferParameterui64vNV(buffer_, GL_BUFFER_GPU_ADDRESS_NV,
&gpu_base_); &gpu_base_);
} }
@ -90,11 +90,16 @@ CircularBuffer::Allocation CircularBuffer::Acquire(size_t length) {
return allocation; return allocation;
} }
void CircularBuffer::Discard(Allocation allocation) {
write_head_ -= allocation.aligned_length;
}
void CircularBuffer::Commit(Allocation allocation) { void CircularBuffer::Commit(Allocation allocation) {
uintptr_t start = allocation.gpu_ptr - gpu_base_; uintptr_t start = allocation.gpu_ptr - gpu_base_;
uintptr_t end = start + allocation.aligned_length; uintptr_t end = start + allocation.aligned_length;
dirty_start_ = std::min(dirty_start_, start); dirty_start_ = std::min(dirty_start_, start);
dirty_end_ = std::max(dirty_end_, end); dirty_end_ = std::max(dirty_end_, end);
assert_true(dirty_end_ <= capacity_);
} }
void CircularBuffer::Flush() { void CircularBuffer::Flush() {

View File

@ -38,6 +38,7 @@ class CircularBuffer {
bool CanAcquire(size_t length); bool CanAcquire(size_t length);
Allocation Acquire(size_t length); Allocation Acquire(size_t length);
void Discard(Allocation allocation);
void Commit(Allocation allocation); void Commit(Allocation allocation);
void Flush(); void Flush();

View File

@ -163,7 +163,6 @@ void CommandProcessor::WorkerMain() {
} }
bool CommandProcessor::SetupGL() { bool CommandProcessor::SetupGL() {
glViewport(0, 0, 1280, 720);
// Circular buffer holding scratch vertex/index data. // Circular buffer holding scratch vertex/index data.
if (!scratch_buffer_.Initialize()) { if (!scratch_buffer_.Initialize()) {
@ -1580,6 +1579,8 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateRenderTargets(
// TODO(benvanik): can we do this all named? // TODO(benvanik): can we do this all named?
// TODO(benvanik): do we want this on READ too? // TODO(benvanik): do we want this on READ too?
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, cached_framebuffer->framebuffer); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, cached_framebuffer->framebuffer);
glViewport(0, 0, 1280, 720);
} }
return UpdateStatus::kMismatch; return UpdateStatus::kMismatch;

View File

@ -936,7 +936,8 @@ bool GL4ShaderTranslator::TranslateALU_RECIP_IEEE(const instr_alu_t& alu) {
return true; 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); AppendDestReg(alu.scalar_dest, alu.scalar_write_mask, alu.export_data);
Append(" = "); Append(" = ");
if (alu.scalar_clamp) { if (alu.scalar_clamp) {
@ -1298,8 +1299,7 @@ bool GL4ShaderTranslator::TranslateALU(const instr_alu_t* alu, int sync) {
} else { } else {
Append("\t \tOP(%u)\t", alu->scalar_opc); Append("\t \tOP(%u)\t", alu->scalar_opc);
} }
PrintDstReg(alu->scalar_dest, alu->scalar_write_mask, PrintDstReg(alu->scalar_dest, alu->scalar_write_mask, alu->export_data);
alu->export_data);
Append(" = "); Append(" = ");
if (is.num_srcs == 2) { if (is.num_srcs == 2) {
// ADD_CONST_0 dest, [const], [reg] // ADD_CONST_0 dest, [const], [reg]

View File

@ -215,6 +215,7 @@ void Shader::GatherVertexFetch(const instr_fetch_vtx_t* vtx) {
desc.stride_words = vtx->stride; desc.stride_words = vtx->stride;
el = &desc.elements[desc.element_count++]; el = &desc.elements[desc.element_count++];
} }
++inputs.total_elements_count;
el->vtx_fetch = *vtx; el->vtx_fetch = *vtx;
el->format = static_cast<VertexFormat>(vtx->format); el->format = static_cast<VertexFormat>(vtx->format);

View File

@ -51,6 +51,7 @@ class Shader {
}; };
struct BufferInputs { struct BufferInputs {
uint32_t count; uint32_t count;
uint32_t total_elements_count;
BufferDesc descs[32]; BufferDesc descs[32];
}; };
const BufferInputs& buffer_inputs() { return buffer_inputs_; } const BufferInputs& buffer_inputs() { return buffer_inputs_; }