Removing NV command list path, as it's unused and untested.
This commit is contained in:
parent
0ebee76bfe
commit
4732378ba9
|
@ -67,7 +67,6 @@ CommandProcessor::CommandProcessor(GL4GraphicsSystem* graphics_system)
|
|||
write_ptr_index_(0),
|
||||
bin_select_(0xFFFFFFFFull),
|
||||
bin_mask_(0xFFFFFFFFull),
|
||||
has_bindless_vbos_(false),
|
||||
active_vertex_shader_(nullptr),
|
||||
active_pixel_shader_(nullptr),
|
||||
active_framebuffer_(nullptr),
|
||||
|
@ -234,10 +233,6 @@ void CommandProcessor::WorkerThreadMain() {
|
|||
}
|
||||
|
||||
bool CommandProcessor::SetupGL() {
|
||||
if (FLAGS_vendor_gl_extensions && GLEW_NV_vertex_buffer_unified_memory) {
|
||||
has_bindless_vbos_ = true;
|
||||
}
|
||||
|
||||
// Circular buffer holding scratch vertex/index data.
|
||||
if (!scratch_buffer_.Initialize()) {
|
||||
XELOGE("Unable to initialize scratch buffer");
|
||||
|
@ -1554,10 +1549,8 @@ bool CommandProcessor::IssueDraw() {
|
|||
if (!draw_batcher_.CommitDraw()) {
|
||||
return false;
|
||||
}
|
||||
if (!has_bindless_vbos_) {
|
||||
// TODO(benvanik): find a way to get around glVertexArrayVertexBuffer below.
|
||||
draw_batcher_.Flush(DrawBatcher::FlushMode::kMakeCoherent);
|
||||
}
|
||||
// TODO(benvanik): find a way to get around glVertexArrayVertexBuffer below.
|
||||
draw_batcher_.Flush(DrawBatcher::FlushMode::kMakeCoherent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1688,15 +1681,8 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateShaders(
|
|||
cached_pipeline->handles.line_quad_list_pipeline = pipelines[4];
|
||||
|
||||
// This can be set once, as the buffer never changes.
|
||||
if (has_bindless_vbos_) {
|
||||
glBindVertexArray(active_vertex_shader_->vao());
|
||||
glBufferAddressRangeNV(GL_ELEMENT_ARRAY_ADDRESS_NV, 0,
|
||||
scratch_buffer_.gpu_handle(),
|
||||
scratch_buffer_.capacity());
|
||||
} else {
|
||||
glVertexArrayElementBuffer(active_vertex_shader_->vao(),
|
||||
scratch_buffer_.handle());
|
||||
}
|
||||
glVertexArrayElementBuffer(active_vertex_shader_->vao(),
|
||||
scratch_buffer_.handle());
|
||||
}
|
||||
|
||||
bool line_mode = false;
|
||||
|
@ -2390,39 +2376,19 @@ CommandProcessor::UpdateStatus CommandProcessor::PopulateVertexBuffers() {
|
|||
memory_->TranslatePhysical<const uint32_t*>(fetch->address << 2),
|
||||
valid_range / 4);
|
||||
|
||||
if (!has_bindless_vbos_) {
|
||||
// TODO(benvanik): if we could find a way to avoid this, we could use
|
||||
// multidraw without flushing.
|
||||
glVertexArrayVertexBuffer(active_vertex_shader_->vao(), buffer_index,
|
||||
scratch_buffer_.handle(), allocation.offset,
|
||||
desc.stride_words * 4);
|
||||
}
|
||||
|
||||
if (has_bindless_vbos_) {
|
||||
for (uint32_t i = 0; i < desc.element_count; ++i, ++el_index) {
|
||||
const auto& el = desc.elements[i];
|
||||
draw_batcher_.set_vertex_buffer(el_index, 0, desc.stride_words * 4,
|
||||
allocation);
|
||||
}
|
||||
}
|
||||
// TODO(benvanik): if we could find a way to avoid this, we could use
|
||||
// multidraw without flushing.
|
||||
glVertexArrayVertexBuffer(active_vertex_shader_->vao(), buffer_index,
|
||||
scratch_buffer_.handle(), allocation.offset,
|
||||
desc.stride_words * 4);
|
||||
|
||||
scratch_buffer_.Commit(std::move(allocation));
|
||||
} else {
|
||||
if (!has_bindless_vbos_) {
|
||||
// TODO(benvanik): if we could find a way to avoid this, we could use
|
||||
// multidraw without flushing.
|
||||
glVertexArrayVertexBuffer(active_vertex_shader_->vao(), buffer_index,
|
||||
scratch_buffer_.handle(), allocation.offset,
|
||||
desc.stride_words * 4);
|
||||
}
|
||||
|
||||
if (has_bindless_vbos_) {
|
||||
for (uint32_t i = 0; i < desc.element_count; ++i, ++el_index) {
|
||||
const auto& el = desc.elements[i];
|
||||
draw_batcher_.set_vertex_buffer(el_index, 0, desc.stride_words * 4,
|
||||
allocation);
|
||||
}
|
||||
}
|
||||
// TODO(benvanik): if we could find a way to avoid this, we could use
|
||||
// multidraw without flushing.
|
||||
glVertexArrayVertexBuffer(active_vertex_shader_->vao(), buffer_index,
|
||||
scratch_buffer_.handle(), allocation.offset,
|
||||
desc.stride_words * 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -259,8 +259,6 @@ class CommandProcessor {
|
|||
uint64_t bin_select_;
|
||||
uint64_t bin_mask_;
|
||||
|
||||
bool has_bindless_vbos_;
|
||||
|
||||
GL4ShaderTranslator shader_translator_;
|
||||
std::vector<std::unique_ptr<GL4Shader>> all_shaders_;
|
||||
std::unordered_map<uint64_t, GL4Shader*> shader_cache_;
|
||||
|
|
|
@ -32,7 +32,6 @@ DrawBatcher::DrawBatcher(RegisterFile* register_file)
|
|||
command_buffer_(kCommandBufferCapacity, kCommandBufferAlignment),
|
||||
state_buffer_(kStateBufferCapacity, kStateBufferAlignment),
|
||||
array_data_buffer_(nullptr),
|
||||
has_bindless_mdi_(false),
|
||||
draw_open_(false) {
|
||||
std::memset(&batch_state_, 0, sizeof(batch_state_));
|
||||
batch_state_.needs_reconfigure = true;
|
||||
|
@ -50,9 +49,6 @@ bool DrawBatcher::Initialize(CircularBuffer* array_data_buffer) {
|
|||
return false;
|
||||
}
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, command_buffer_.handle());
|
||||
if (FLAGS_vendor_gl_extensions && GLEW_NV_bindless_multi_draw_indirect) {
|
||||
has_bindless_mdi_ = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -133,10 +129,6 @@ bool DrawBatcher::BeginDrawElements(PrimitiveType prim_type,
|
|||
cmd->first_index = start_index;
|
||||
cmd->base_vertex = 0;
|
||||
|
||||
if (has_bindless_mdi_) {
|
||||
auto bindless_cmd = active_draw_.draw_elements_bindless_cmd;
|
||||
bindless_cmd->reserved_zero = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -153,18 +145,10 @@ bool DrawBatcher::BeginDraw() {
|
|||
|
||||
// Padded to max.
|
||||
GLsizei command_size = 0;
|
||||
if (has_bindless_mdi_) {
|
||||
if (batch_state_.indexed) {
|
||||
command_size = sizeof(DrawElementsIndirectBindlessCommandNV);
|
||||
} else {
|
||||
command_size = sizeof(DrawArraysIndirectBindlessCommandNV);
|
||||
}
|
||||
if (batch_state_.indexed) {
|
||||
command_size = sizeof(DrawElementsIndirectCommand);
|
||||
} else {
|
||||
if (batch_state_.indexed) {
|
||||
command_size = sizeof(DrawElementsIndirectCommand);
|
||||
} else {
|
||||
command_size = sizeof(DrawArraysIndirectCommand);
|
||||
}
|
||||
command_size = sizeof(DrawArraysIndirectCommand);
|
||||
}
|
||||
batch_state_.command_stride =
|
||||
xe::round_up(command_size, GLsizei(kCommandBufferAlignment));
|
||||
|
@ -322,48 +306,32 @@ bool DrawBatcher::Flush(FlushMode mode) {
|
|||
void* indirect_offset =
|
||||
reinterpret_cast<void*>(batch_state_.command_range_start);
|
||||
|
||||
if (has_bindless_mdi_) {
|
||||
int vertex_buffer_count =
|
||||
batch_state_.vertex_shader->buffer_inputs().total_elements_count;
|
||||
assert_true(vertex_buffer_count < 8);
|
||||
if (batch_state_.draw_count == 1) {
|
||||
// Fast path for one draw. Removes MDI overhead when not required.
|
||||
if (batch_state_.indexed) {
|
||||
glMultiDrawElementsIndirectBindlessNV(
|
||||
prim_type, batch_state_.index_type, indirect_offset,
|
||||
batch_state_.draw_count, batch_state_.command_stride,
|
||||
vertex_buffer_count);
|
||||
auto& cmd = active_draw_.draw_elements_cmd;
|
||||
glDrawElementsInstancedBaseVertexBaseInstance(
|
||||
prim_type, cmd->count, batch_state_.index_type,
|
||||
reinterpret_cast<void*>(
|
||||
uintptr_t(cmd->first_index) *
|
||||
(batch_state_.index_type == GL_UNSIGNED_SHORT ? 2 : 4)),
|
||||
cmd->instance_count, cmd->base_vertex, cmd->base_instance);
|
||||
} else {
|
||||
glMultiDrawArraysIndirectBindlessNV(
|
||||
prim_type, indirect_offset, batch_state_.draw_count,
|
||||
batch_state_.command_stride, vertex_buffer_count);
|
||||
auto& cmd = active_draw_.draw_arrays_cmd;
|
||||
glDrawArraysInstancedBaseInstance(prim_type, cmd->first_index,
|
||||
cmd->count, cmd->instance_count,
|
||||
cmd->base_instance);
|
||||
}
|
||||
} else {
|
||||
if (batch_state_.draw_count == 1) {
|
||||
// Fast path for one draw. Removes MDI overhead when not required.
|
||||
if (batch_state_.indexed) {
|
||||
auto& cmd = active_draw_.draw_elements_cmd;
|
||||
glDrawElementsInstancedBaseVertexBaseInstance(
|
||||
prim_type, cmd->count, batch_state_.index_type,
|
||||
reinterpret_cast<void*>(
|
||||
uintptr_t(cmd->first_index) *
|
||||
(batch_state_.index_type == GL_UNSIGNED_SHORT ? 2 : 4)),
|
||||
cmd->instance_count, cmd->base_vertex, cmd->base_instance);
|
||||
} else {
|
||||
auto& cmd = active_draw_.draw_arrays_cmd;
|
||||
glDrawArraysInstancedBaseInstance(prim_type, cmd->first_index,
|
||||
cmd->count, cmd->instance_count,
|
||||
cmd->base_instance);
|
||||
}
|
||||
} else {
|
||||
// Full multi-draw.
|
||||
if (batch_state_.indexed) {
|
||||
glMultiDrawElementsIndirect(prim_type, batch_state_.index_type,
|
||||
indirect_offset, batch_state_.draw_count,
|
||||
batch_state_.command_stride);
|
||||
} else {
|
||||
glMultiDrawArraysIndirect(prim_type, indirect_offset,
|
||||
batch_state_.draw_count,
|
||||
// Full multi-draw.
|
||||
if (batch_state_.indexed) {
|
||||
glMultiDrawElementsIndirect(prim_type, batch_state_.index_type,
|
||||
indirect_offset, batch_state_.draw_count,
|
||||
batch_state_.command_stride);
|
||||
}
|
||||
} else {
|
||||
glMultiDrawArraysIndirect(prim_type, indirect_offset,
|
||||
batch_state_.draw_count,
|
||||
batch_state_.command_stride);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,24 +43,6 @@ struct DrawElementsIndirectCommand {
|
|||
GLint base_vertex;
|
||||
GLuint base_instance;
|
||||
};
|
||||
struct BindlessPtrNV {
|
||||
GLuint index;
|
||||
GLuint reserved_zero;
|
||||
GLuint64 address;
|
||||
GLuint64 length;
|
||||
};
|
||||
struct DrawArraysIndirectBindlessCommandNV {
|
||||
DrawArraysIndirectCommand cmd;
|
||||
// NOTE: the spec is wrong here. For fucks sake.
|
||||
// GLuint reserved_zero;
|
||||
BindlessPtrNV vertex_buffers[8];
|
||||
};
|
||||
struct DrawElementsIndirectBindlessCommandNV {
|
||||
DrawElementsIndirectCommand cmd;
|
||||
GLuint reserved_zero;
|
||||
BindlessPtrNV index_buffer;
|
||||
BindlessPtrNV vertex_buffers[8];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
class DrawBatcher {
|
||||
|
@ -97,33 +79,10 @@ class DrawBatcher {
|
|||
active_draw_.header->texture_samplers[index] = handle;
|
||||
}
|
||||
void set_index_buffer(const CircularBuffer::Allocation& allocation) {
|
||||
if (has_bindless_mdi_) {
|
||||
auto& ptr = active_draw_.draw_elements_bindless_cmd->index_buffer;
|
||||
ptr.reserved_zero = 0;
|
||||
ptr.index = 0;
|
||||
ptr.address = allocation.gpu_ptr;
|
||||
ptr.length = allocation.length;
|
||||
} else {
|
||||
// Offset is used in glDrawElements.
|
||||
auto& cmd = active_draw_.draw_elements_cmd;
|
||||
size_t index_size = batch_state_.index_type == GL_UNSIGNED_SHORT ? 2 : 4;
|
||||
cmd->first_index = GLuint(allocation.offset / index_size);
|
||||
}
|
||||
}
|
||||
void set_vertex_buffer(int index, GLsizei offset, GLsizei stride,
|
||||
const CircularBuffer::Allocation& allocation) {
|
||||
if (has_bindless_mdi_) {
|
||||
BindlessPtrNV* ptr;
|
||||
if (batch_state_.indexed) {
|
||||
ptr = &active_draw_.draw_elements_bindless_cmd->vertex_buffers[index];
|
||||
} else {
|
||||
ptr = &active_draw_.draw_arrays_bindless_cmd->vertex_buffers[index];
|
||||
}
|
||||
ptr->reserved_zero = 0;
|
||||
ptr->index = index;
|
||||
ptr->address = allocation.gpu_ptr + offset;
|
||||
ptr->length = allocation.length - offset;
|
||||
}
|
||||
// Offset is used in glDrawElements.
|
||||
auto& cmd = active_draw_.draw_elements_cmd;
|
||||
size_t index_size = batch_state_.index_type == GL_UNSIGNED_SHORT ? 2 : 4;
|
||||
cmd->first_index = GLuint(allocation.offset / index_size);
|
||||
}
|
||||
|
||||
bool ReconfigurePipeline(GL4Shader* vertex_shader, GL4Shader* pixel_shader,
|
||||
|
@ -145,8 +104,6 @@ class DrawBatcher {
|
|||
CircularBuffer state_buffer_;
|
||||
CircularBuffer* array_data_buffer_;
|
||||
|
||||
bool has_bindless_mdi_;
|
||||
|
||||
struct BatchState {
|
||||
bool needs_reconfigure;
|
||||
PrimitiveType prim_type;
|
||||
|
@ -190,8 +147,6 @@ class DrawBatcher {
|
|||
union {
|
||||
DrawArraysIndirectCommand* draw_arrays_cmd;
|
||||
DrawElementsIndirectCommand* draw_elements_cmd;
|
||||
DrawArraysIndirectBindlessCommandNV* draw_arrays_bindless_cmd;
|
||||
DrawElementsIndirectBindlessCommandNV* draw_elements_bindless_cmd;
|
||||
uintptr_t command_address;
|
||||
};
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
|
||||
#include "xenia/gpu/gl4/gl4_gpu_flags.h"
|
||||
|
||||
DEFINE_bool(vendor_gl_extensions, false,
|
||||
"Enable vendor-specific (NV, AMD, etc) GL extensions.");
|
||||
|
||||
DEFINE_bool(disable_framebuffer_readback, false,
|
||||
"Disable framebuffer readback.");
|
||||
DEFINE_bool(disable_textures, false, "Disable textures and use colors only.");
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
DECLARE_bool(vendor_gl_extensions);
|
||||
|
||||
DECLARE_bool(disable_framebuffer_readback);
|
||||
DECLARE_bool(disable_textures);
|
||||
|
||||
|
|
|
@ -126,15 +126,6 @@ std::string GL4Shader::GetFooter() {
|
|||
bool GL4Shader::PrepareVertexArrayObject() {
|
||||
glCreateVertexArrays(1, &vao_);
|
||||
|
||||
bool has_bindless_vbos = false;
|
||||
if (FLAGS_vendor_gl_extensions && GLEW_NV_vertex_buffer_unified_memory) {
|
||||
has_bindless_vbos = true;
|
||||
// Nasty, but no DSA for this.
|
||||
glBindVertexArray(vao_);
|
||||
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV);
|
||||
glEnableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV);
|
||||
}
|
||||
|
||||
uint32_t el_index = 0;
|
||||
for (uint32_t buffer_index = 0; buffer_index < buffer_inputs_.count;
|
||||
++buffer_index) {
|
||||
|
@ -198,24 +189,12 @@ bool GL4Shader::PrepareVertexArrayObject() {
|
|||
}
|
||||
|
||||
glEnableVertexArrayAttrib(vao_, el_index);
|
||||
if (has_bindless_vbos) {
|
||||
// NOTE: MultiDrawIndirectBindlessMumble doesn't handle separate
|
||||
// vertex bindings/formats.
|
||||
glVertexAttribFormat(el_index, comp_count, comp_type, el.is_normalized,
|
||||
el.offset_words * 4);
|
||||
glVertexArrayVertexBuffer(vao_, el_index, 0, 0, desc.stride_words * 4);
|
||||
} else {
|
||||
glVertexArrayAttribBinding(vao_, el_index, buffer_index);
|
||||
glVertexArrayAttribFormat(vao_, el_index, comp_count, comp_type,
|
||||
el.is_normalized, el.offset_words * 4);
|
||||
}
|
||||
glVertexArrayAttribBinding(vao_, el_index, buffer_index);
|
||||
glVertexArrayAttribFormat(vao_, el_index, comp_count, comp_type,
|
||||
el.is_normalized, el.offset_words * 4);
|
||||
}
|
||||
}
|
||||
|
||||
if (has_bindless_vbos) {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,12 +41,6 @@ bool CircularBuffer::Initialize() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (FLAGS_vendor_gl_extensions && GLEW_NV_shader_buffer_load) {
|
||||
// To use this bindlessly we must make it resident.
|
||||
glMakeNamedBufferResidentNV(buffer_, GL_READ_ONLY);
|
||||
glGetNamedBufferParameterui64vNV(buffer_, GL_BUFFER_GPU_ADDRESS_NV,
|
||||
&gpu_base_);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,9 +49,6 @@ void CircularBuffer::Shutdown() {
|
|||
return;
|
||||
}
|
||||
glUnmapNamedBuffer(buffer_);
|
||||
if (FLAGS_vendor_gl_extensions && GLEW_NV_shader_buffer_load) {
|
||||
glMakeNamedBufferNonResidentNV(buffer_);
|
||||
}
|
||||
glDeleteBuffers(1, &buffer_);
|
||||
buffer_ = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue