GL: Remove base instance workaround
This commit is contained in:
committed by
Clément Foucault
parent
6722d40fd5
commit
64d1f065e3
@@ -318,7 +318,6 @@ static void detect_workarounds()
|
||||
/* Do not alter OpenGL 4.3 features.
|
||||
* These code paths should be removed. */
|
||||
GCaps.shader_image_load_store_support = false;
|
||||
GLContext::base_instance_support = false;
|
||||
GLContext::copy_image_support = false;
|
||||
GLContext::debug_layer_support = false;
|
||||
GLContext::geometry_shader_invocations = false;
|
||||
@@ -337,16 +336,6 @@ static void detect_workarounds()
|
||||
GCaps.use_main_context_workaround = true;
|
||||
}
|
||||
|
||||
/* Limit support for GL_ARB_base_instance to OpenGL 4.0 and higher. NVIDIA Quadro FX 4800
|
||||
* (TeraScale) report that they support GL_ARB_base_instance, but the driver does not support
|
||||
* GLEW_ARB_draw_indirect as it has an OpenGL3 context what also matches the minimum needed
|
||||
* requirements.
|
||||
*
|
||||
* We use it as a target for glMapBuffer(Range) what is part of the OpenGL 4 API. So better
|
||||
* disable it when we don't have an OpenGL4 context (See #77657) */
|
||||
if (!(epoxy_gl_version() >= 40)) {
|
||||
GLContext::base_instance_support = false;
|
||||
}
|
||||
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_WIN, GPU_DRIVER_OFFICIAL) &&
|
||||
(strstr(version, "4.5.13399") || strstr(version, "4.5.13417") ||
|
||||
strstr(version, "4.5.13422") || strstr(version, "4.5.13467")))
|
||||
@@ -432,7 +421,6 @@ static void detect_workarounds()
|
||||
strstr(version, "Build 10.18.10.5") || strstr(version, "Build 10.18.14.4") ||
|
||||
strstr(version, "Build 10.18.14.5")))
|
||||
{
|
||||
GLContext::base_instance_support = false;
|
||||
GCaps.use_main_context_workaround = true;
|
||||
}
|
||||
/* Somehow fixes armature display issues (see #69743). */
|
||||
@@ -520,7 +508,6 @@ GLint GLContext::max_ssbo_binds = 0;
|
||||
|
||||
/** Extensions. */
|
||||
|
||||
bool GLContext::base_instance_support = false;
|
||||
bool GLContext::clear_texture_support = false;
|
||||
bool GLContext::copy_image_support = false;
|
||||
bool GLContext::debug_layer_support = false;
|
||||
@@ -612,7 +599,6 @@ void GLBackend::capabilities_init()
|
||||
GLContext::max_ssbo_binds = min_ii(GLContext::max_ssbo_binds, max_ssbo_binds);
|
||||
glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &max_ssbo_binds);
|
||||
GLContext::max_ssbo_binds = min_ii(GLContext::max_ssbo_binds, max_ssbo_binds);
|
||||
GLContext::base_instance_support = epoxy_has_gl_extension("GL_ARB_base_instance");
|
||||
GLContext::clear_texture_support = epoxy_has_gl_extension("GL_ARB_clear_texture");
|
||||
GLContext::copy_image_support = epoxy_has_gl_extension("GL_ARB_copy_image");
|
||||
GLContext::debug_layer_support = epoxy_gl_version() >= 43 ||
|
||||
|
||||
@@ -208,29 +208,6 @@ void GLVaoCache::context_check()
|
||||
}
|
||||
}
|
||||
|
||||
GLuint GLVaoCache::base_instance_vao_get(GPUBatch *batch, int i_first)
|
||||
{
|
||||
this->context_check();
|
||||
/* Make sure the interface is up to date. */
|
||||
Shader *shader = GLContext::get()->shader;
|
||||
GLShaderInterface *interface = static_cast<GLShaderInterface *>(shader->interface);
|
||||
if (interface_ != interface) {
|
||||
vao_get(batch);
|
||||
/* Trigger update. */
|
||||
base_instance_ = 0;
|
||||
}
|
||||
|
||||
if (vao_base_instance_ == 0) {
|
||||
glGenVertexArrays(1, &vao_base_instance_);
|
||||
}
|
||||
|
||||
if (base_instance_ != i_first) {
|
||||
base_instance_ = i_first;
|
||||
GLVertArray::update_bindings(vao_base_instance_, batch, interface_, i_first);
|
||||
}
|
||||
return vao_base_instance_;
|
||||
}
|
||||
|
||||
GLuint GLVaoCache::vao_get(GPUBatch *batch)
|
||||
{
|
||||
this->context_check();
|
||||
@@ -258,7 +235,7 @@ GLuint GLVaoCache::vao_get(GPUBatch *batch)
|
||||
/** \name Drawing
|
||||
* \{ */
|
||||
|
||||
void GLBatch::bind(int i_first)
|
||||
void GLBatch::bind()
|
||||
{
|
||||
GLContext::get()->state_manager->apply_state();
|
||||
|
||||
@@ -267,20 +244,14 @@ void GLBatch::bind(int i_first)
|
||||
vao_cache_.clear();
|
||||
}
|
||||
|
||||
/* Can be removed if GL 4.2 is required. */
|
||||
if (!GLContext::base_instance_support && (i_first > 0)) {
|
||||
glBindVertexArray(vao_cache_.base_instance_vao_get(this, i_first));
|
||||
}
|
||||
else {
|
||||
glBindVertexArray(vao_cache_.vao_get(this));
|
||||
}
|
||||
glBindVertexArray(vao_cache_.vao_get(this));
|
||||
}
|
||||
|
||||
void GLBatch::draw(int v_first, int v_count, int i_first, int i_count)
|
||||
{
|
||||
GL_CHECK_RESOURCES("Batch");
|
||||
|
||||
this->bind(i_first);
|
||||
this->bind();
|
||||
|
||||
BLI_assert(v_count > 0 && i_count > 0);
|
||||
|
||||
@@ -292,22 +263,11 @@ void GLBatch::draw(int v_first, int v_count, int i_first, int i_count)
|
||||
GLint base_index = el->index_base_;
|
||||
void *v_first_ofs = el->offset_ptr(v_first);
|
||||
|
||||
if (GLContext::base_instance_support) {
|
||||
glDrawElementsInstancedBaseVertexBaseInstance(
|
||||
gl_type, v_count, index_type, v_first_ofs, i_count, base_index, i_first);
|
||||
}
|
||||
else {
|
||||
glDrawElementsInstancedBaseVertex(
|
||||
gl_type, v_count, index_type, v_first_ofs, i_count, base_index);
|
||||
}
|
||||
glDrawElementsInstancedBaseVertexBaseInstance(
|
||||
gl_type, v_count, index_type, v_first_ofs, i_count, base_index, i_first);
|
||||
}
|
||||
else {
|
||||
if (GLContext::base_instance_support) {
|
||||
glDrawArraysInstancedBaseInstance(gl_type, v_first, v_count, i_count, i_first);
|
||||
}
|
||||
else {
|
||||
glDrawArraysInstanced(gl_type, v_first, v_count, i_count);
|
||||
}
|
||||
glDrawArraysInstancedBaseInstance(gl_type, v_first, v_count, i_count, i_first);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +275,7 @@ void GLBatch::draw_indirect(GPUStorageBuf *indirect_buf, intptr_t offset)
|
||||
{
|
||||
GL_CHECK_RESOURCES("Batch");
|
||||
|
||||
this->bind(0);
|
||||
this->bind();
|
||||
|
||||
/* TODO(fclem): Make the barrier and binding optional if consecutive draws are issued. */
|
||||
dynamic_cast<GLStorageBuf *>(unwrap(indirect_buf))->bind_as(GL_DRAW_INDIRECT_BUFFER);
|
||||
@@ -342,7 +302,7 @@ void GLBatch::multi_draw_indirect(GPUStorageBuf *indirect_buf,
|
||||
{
|
||||
GL_CHECK_RESOURCES("Batch");
|
||||
|
||||
this->bind(0);
|
||||
this->bind();
|
||||
|
||||
/* TODO(fclem): Make the barrier and binding optional if consecutive draws are issued. */
|
||||
dynamic_cast<GLStorageBuf *>(unwrap(indirect_buf))->bind_as(GL_DRAW_INDIRECT_BUFFER);
|
||||
|
||||
@@ -63,7 +63,6 @@ class GLVaoCache {
|
||||
~GLVaoCache();
|
||||
|
||||
GLuint vao_get(GPUBatch *batch);
|
||||
GLuint base_instance_vao_get(GPUBatch *batch, int i_first);
|
||||
|
||||
/**
|
||||
* Return 0 on cache miss (invalid VAO).
|
||||
@@ -97,7 +96,7 @@ class GLBatch : public Batch {
|
||||
int count,
|
||||
intptr_t offset,
|
||||
intptr_t stride) override;
|
||||
void bind(int i_first);
|
||||
void bind();
|
||||
|
||||
/* Convenience getters. */
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ class GLContext : public Context {
|
||||
|
||||
/** Extensions. */
|
||||
|
||||
static bool base_instance_support;
|
||||
static bool clear_texture_support;
|
||||
static bool copy_image_support;
|
||||
static bool debug_layer_support;
|
||||
|
||||
@@ -182,7 +182,7 @@ void GLDrawList::submit()
|
||||
data_ = nullptr; /* Unmapped */
|
||||
data_offset_ += command_offset_;
|
||||
|
||||
batch_->bind(0);
|
||||
batch_->bind();
|
||||
|
||||
if (MDI_INDEXED) {
|
||||
GLenum gl_type = to_gl(batch_->elem_()->index_type_);
|
||||
|
||||
Reference in New Issue
Block a user