GPU: Remove Shader Draw Parameter workaround
With 5.0 we start requiring this extension for GL and VK.
All of our target hardware supports it with up to date
drivers.
Some old drivers were disabling this extension because of
buggy behavior. We simply drop support for them in 5.0.
This allows us to remove a lot of code and the last
shader create info override done at startup. This will
unlock more refactoring of the shader create info into
static classes to reduce binary size and other benefits.
## TODO:
- [x] Remove checks for ARB_shader_draw_parameters
- [x] Remove checks for ARB_clip_control
- [x] Check for the extension on startup for OpenGL
- [x] Check for the extension on startup for Vulkan
- [x] ~~Add user facing popup message about minimum
requirements not being met.~~ Done using the same
popup as old hardware.
Pull Request: https://projects.blender.org/blender/blender/pulls/142334
This commit is contained in:
@@ -306,7 +306,7 @@ class GHOST_DeviceVK {
|
||||
/* Enable vulkan 11 features when supported on physical device. */
|
||||
VkPhysicalDeviceVulkan11Features vulkan_11_features = {};
|
||||
vulkan_11_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES;
|
||||
vulkan_11_features.shaderDrawParameters = features_11.shaderDrawParameters;
|
||||
vulkan_11_features.shaderDrawParameters = VK_TRUE;
|
||||
feature_struct_ptr.push_back(&vulkan_11_features);
|
||||
|
||||
/* Enable optional vulkan 12 features when supported on physical device. */
|
||||
|
||||
@@ -281,8 +281,7 @@ void Film::init(const int2 &extent, const rcti *output_rect)
|
||||
}
|
||||
}
|
||||
|
||||
this->depth = GPU_clip_control_support() ? DepthState{0.0f, DRW_STATE_DEPTH_GREATER_EQUAL} :
|
||||
DepthState{1.0f, DRW_STATE_DEPTH_LESS_EQUAL};
|
||||
this->depth = DepthState{0.0f, DRW_STATE_DEPTH_GREATER_EQUAL};
|
||||
|
||||
/* Compute the passes needed by the viewport compositor. */
|
||||
Set<std::string> passes_used_by_viewport_compositor;
|
||||
|
||||
@@ -175,10 +175,6 @@ void Draw::execute(RecordingState &state) const
|
||||
{
|
||||
state.front_facing_set(res_index.has_inverted_handedness());
|
||||
|
||||
if (GPU_shader_draw_parameters_support() == false) {
|
||||
GPU_batch_resource_id_buf_set(batch, state.resource_id_buf);
|
||||
}
|
||||
|
||||
/* Use same logic as in `finalize_commands`. */
|
||||
uint instance_first = 0;
|
||||
if (res_index.raw > 0) {
|
||||
@@ -235,10 +231,6 @@ void DrawMulti::execute(RecordingState &state) const
|
||||
batch = procedural_batch_get(GPUPrimType(group.desc.expand_prim_type));
|
||||
}
|
||||
|
||||
if (GPU_shader_draw_parameters_support() == false) {
|
||||
GPU_batch_resource_id_buf_set(batch, state.resource_id_buf);
|
||||
}
|
||||
|
||||
GPU_batch_set_shader(batch, state.shader, state.specialization_constants_get());
|
||||
|
||||
constexpr intptr_t stride = sizeof(DrawCommand);
|
||||
@@ -789,14 +781,9 @@ void DrawCommandBuf::generate_commands(Vector<Header, 0> &headers,
|
||||
resource_id_buf_.push_update();
|
||||
}
|
||||
|
||||
void DrawCommandBuf::bind(RecordingState &state)
|
||||
void DrawCommandBuf::bind(RecordingState & /*state*/)
|
||||
{
|
||||
if (GPU_shader_draw_parameters_support() == false) {
|
||||
state.resource_id_buf = resource_id_buf_;
|
||||
}
|
||||
else {
|
||||
GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
|
||||
}
|
||||
GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
|
||||
}
|
||||
|
||||
void DrawMultiBuf::generate_commands(Vector<Header, 0> & /*headers*/,
|
||||
@@ -873,26 +860,16 @@ void DrawMultiBuf::generate_commands(Vector<Header, 0> & /*headers*/,
|
||||
GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
|
||||
GPU_compute_dispatch(shader, divide_ceil_u(prototype_count_, DRW_COMMAND_GROUP_SIZE), 1, 1);
|
||||
/* TODO(@fclem): Investigate moving the barrier in the bind function. */
|
||||
if (GPU_shader_draw_parameters_support() == false) {
|
||||
GPU_memory_barrier(GPU_BARRIER_VERTEX_ATTRIB_ARRAY);
|
||||
}
|
||||
else {
|
||||
GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE);
|
||||
}
|
||||
GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE);
|
||||
GPU_storagebuf_sync_as_indirect_buffer(command_buf_);
|
||||
}
|
||||
|
||||
GPU_debug_group_end();
|
||||
}
|
||||
|
||||
void DrawMultiBuf::bind(RecordingState &state)
|
||||
void DrawMultiBuf::bind(RecordingState & /*state*/)
|
||||
{
|
||||
if (GPU_shader_draw_parameters_support() == false) {
|
||||
state.resource_id_buf = resource_id_buf_;
|
||||
}
|
||||
else {
|
||||
GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
|
||||
}
|
||||
GPU_storagebuf_bind(resource_id_buf_, DRW_RESOURCE_ID_SLOT);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -54,8 +54,6 @@ struct RecordingState {
|
||||
bool inverted_view = false;
|
||||
DRWState pipeline_state = DRW_STATE_NO_DRAW;
|
||||
int clip_plane_count = 0;
|
||||
/** Used for gl_BaseInstance workaround. */
|
||||
gpu::StorageBuf *resource_id_buf = nullptr;
|
||||
/** Used for pass simple resource ID. Starts at 1 as 0 is the identity handle. */
|
||||
int instance_offset = 1;
|
||||
|
||||
|
||||
@@ -23,18 +23,10 @@ SHADER_LIBRARY_CREATE_INFO(draw_resource_id_varying)
|
||||
uint drw_resource_id_raw()
|
||||
{
|
||||
#if defined(GPU_VERTEX_SHADER)
|
||||
# if defined(RESOURCE_ID_FALLBACK)
|
||||
# ifdef WITH_CUSTOM_IDS
|
||||
uint id = in_resource_id_custom_id.x;
|
||||
# else
|
||||
uint id = in_resource_id;
|
||||
# endif
|
||||
# else
|
||||
# ifdef WITH_CUSTOM_IDS
|
||||
# ifdef WITH_CUSTOM_IDS
|
||||
uint id = resource_id_buf[gpu_BaseInstance + gl_InstanceID].x;
|
||||
# else
|
||||
# else
|
||||
uint id = resource_id_buf[gpu_BaseInstance + gl_InstanceID];
|
||||
# endif
|
||||
# endif
|
||||
return id;
|
||||
|
||||
@@ -53,12 +45,8 @@ uint drw_custom_id()
|
||||
{
|
||||
#ifdef WITH_CUSTOM_IDS
|
||||
# if defined(GPU_VERTEX_SHADER)
|
||||
# if defined(RESOURCE_ID_FALLBACK)
|
||||
return in_resource_id_custom_id.y;
|
||||
# else
|
||||
uint inst_id = gpu_BaseInstance + gl_InstanceID;
|
||||
return resource_id_buf[gpu_BaseInstance + gl_InstanceID].y;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
@@ -48,20 +48,6 @@ DEFINE("WITH_CUSTOM_IDS")
|
||||
STORAGE_BUF(DRW_RESOURCE_ID_SLOT, read, uint2, resource_id_buf[])
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
/**
|
||||
* Workaround the lack of gl_BaseInstance by binding the resource_id_buf as vertex buf.
|
||||
*/
|
||||
GPU_SHADER_CREATE_INFO(draw_resource_id_fallback)
|
||||
DEFINE("RESOURCE_ID_FALLBACK")
|
||||
VERTEX_IN(15, uint, in_resource_id)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
GPU_SHADER_CREATE_INFO(draw_resource_with_custom_id_fallback)
|
||||
DEFINE("RESOURCE_ID_FALLBACK")
|
||||
DEFINE("WITH_CUSTOM_IDS")
|
||||
VERTEX_IN(15, uint2, in_resource_id_custom_id)
|
||||
GPU_SHADER_CREATE_END()
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -84,8 +84,6 @@ class Batch {
|
||||
blender::gpu::VertBuf *inst[GPU_BATCH_INST_VBO_MAX_LEN];
|
||||
/** nullptr if element list not needed */
|
||||
blender::gpu::IndexBuf *elem;
|
||||
/** Resource ID attribute workaround. */
|
||||
blender::gpu::StorageBuf *resource_id_buf;
|
||||
/** Number of vertices to draw for procedural drawcalls. */
|
||||
int32_t procedural_vertices;
|
||||
/** Bookkeeping. */
|
||||
@@ -261,14 +259,6 @@ void GPU_batch_elembuf_set(blender::gpu::Batch *batch,
|
||||
bool GPU_batch_vertbuf_has(const blender::gpu::Batch *batch,
|
||||
const blender::gpu::VertBuf *vertex_buf);
|
||||
|
||||
/**
|
||||
* Set resource id buffer to bind as instance attribute to workaround the lack of gl_BaseInstance
|
||||
* on some hardware / platform.
|
||||
* \note Only to be used by draw manager.
|
||||
*/
|
||||
void GPU_batch_resource_id_buf_set(blender::gpu::Batch *batch,
|
||||
blender::gpu::StorageBuf *resource_id_buf);
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -54,10 +54,8 @@ bool GPU_use_hq_normals_workaround();
|
||||
bool GPU_crappy_amd_driver();
|
||||
|
||||
bool GPU_geometry_shader_support();
|
||||
bool GPU_shader_draw_parameters_support();
|
||||
bool GPU_hdr_support();
|
||||
bool GPU_stencil_export_support();
|
||||
bool GPU_clip_control_support();
|
||||
|
||||
bool GPU_mem_stats_supported();
|
||||
void GPU_mem_stats_get(int *r_totalmem, int *r_freemem);
|
||||
|
||||
@@ -35,7 +35,6 @@ void GPU_batch_zero(Batch *batch)
|
||||
std::fill_n(batch->verts, ARRAY_SIZE(batch->verts), nullptr);
|
||||
std::fill_n(batch->inst, ARRAY_SIZE(batch->inst), nullptr);
|
||||
batch->elem = nullptr;
|
||||
batch->resource_id_buf = nullptr;
|
||||
batch->flag = eGPUBatchFlag(0);
|
||||
batch->prim_type = GPUPrimType(0);
|
||||
batch->shader = nullptr;
|
||||
@@ -230,13 +229,6 @@ bool GPU_batch_vertbuf_has(const Batch *batch, const VertBuf *vertex_buf)
|
||||
return false;
|
||||
}
|
||||
|
||||
void GPU_batch_resource_id_buf_set(Batch *batch, blender::gpu::StorageBuf *resource_id_buf)
|
||||
{
|
||||
BLI_assert(resource_id_buf);
|
||||
batch->flag |= GPU_BATCH_DIRTY;
|
||||
batch->resource_id_buf = resource_id_buf;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -177,11 +177,6 @@ bool GPU_geometry_shader_support()
|
||||
return GCaps.geometry_shader_support;
|
||||
}
|
||||
|
||||
bool GPU_shader_draw_parameters_support()
|
||||
{
|
||||
return GCaps.shader_draw_parameters_support;
|
||||
}
|
||||
|
||||
bool GPU_hdr_support()
|
||||
{
|
||||
return GCaps.hdr_viewport_support;
|
||||
@@ -192,11 +187,6 @@ bool GPU_stencil_export_support()
|
||||
return GCaps.stencil_export_support;
|
||||
}
|
||||
|
||||
bool GPU_clip_control_support()
|
||||
{
|
||||
return GCaps.clip_control_support;
|
||||
}
|
||||
|
||||
int GPU_max_shader_storage_buffer_bindings()
|
||||
{
|
||||
return GCaps.max_shader_storage_buffer_bindings;
|
||||
|
||||
@@ -46,10 +46,8 @@ struct GPUCapabilities {
|
||||
|
||||
bool mem_stats_support = false;
|
||||
bool geometry_shader_support = false;
|
||||
bool shader_draw_parameters_support = false;
|
||||
bool hdr_viewport_support = false;
|
||||
bool stencil_export_support = false;
|
||||
bool clip_control_support = false;
|
||||
|
||||
int max_parallel_compilations = -1;
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ void GPUCodegen::generate_attribs()
|
||||
/* Input declaration, loading / assignment to interface and geometry shader passthrough. */
|
||||
std::stringstream load_ss;
|
||||
|
||||
int slot = GPU_shader_draw_parameters_support() ? 15 : 14;
|
||||
int slot = 15;
|
||||
LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph.attributes) {
|
||||
if (slot == -1) {
|
||||
BLI_assert_msg(0, "Too many attributes");
|
||||
|
||||
@@ -516,12 +516,6 @@ void gpu_shader_create_info_init()
|
||||
/* Declare, register and construct the infos. */
|
||||
#include "gpu_shader_create_info_list.hh"
|
||||
|
||||
/* WORKAROUND: Replace the use of gpu_BaseInstance by an instance attribute. */
|
||||
if (GPU_shader_draw_parameters_support() == false) {
|
||||
draw_resource_id = draw_resource_id_fallback;
|
||||
draw_resource_with_custom_id = draw_resource_with_custom_id_fallback;
|
||||
}
|
||||
|
||||
if (GPU_stencil_clasify_buffer_workaround()) {
|
||||
/* WORKAROUND: Adding a dummy buffer that isn't used fixes a bug inside the Qualcomm driver. */
|
||||
eevee_deferred_tile_classify.storage_buf(
|
||||
|
||||
@@ -520,7 +520,6 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
|
||||
|
||||
/* Feature support */
|
||||
GCaps.mem_stats_support = false;
|
||||
GCaps.shader_draw_parameters_support = true;
|
||||
GCaps.hdr_viewport_support = true;
|
||||
|
||||
GCaps.geometry_shader_support = false;
|
||||
@@ -551,7 +550,6 @@ void MTLBackend::capabilities_init(MTLContext *ctx)
|
||||
GCaps.max_work_group_size[2] = max_threads_per_threadgroup_per_dim;
|
||||
|
||||
GCaps.stencil_export_support = true;
|
||||
GCaps.clip_control_support = true;
|
||||
|
||||
/* OPENGL Related workarounds -- none needed for Metal. */
|
||||
GCaps.extensions_len = 0;
|
||||
|
||||
@@ -270,6 +270,14 @@ void GLBackend::platform_init()
|
||||
support_level = GPU_SUPPORT_LEVEL_LIMITED;
|
||||
}
|
||||
}
|
||||
if ((device & GPU_DEVICE_QUALCOMM) && (os & GPU_OS_WIN)) {
|
||||
if (strstr(version, "Mesa 20.") || strstr(version, "Mesa 21.") ||
|
||||
strstr(version, "Mesa 22.") || strstr(version, "Mesa 23."))
|
||||
{
|
||||
std::cerr << "Unsupported driver. Requires at least Mesa 24.0.0." << std::endl;
|
||||
support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check SSBO bindings requirement. */
|
||||
GLint max_ssbo_binds_vertex;
|
||||
@@ -285,6 +293,16 @@ void GLBackend::platform_init()
|
||||
<< " SSBO binding locations\n";
|
||||
support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (!epoxy_has_gl_extension("GL_ARB_shader_draw_parameters")) {
|
||||
std::cout << "Error: The OpenGL implementation doesn't support ARB_shader_draw_parameters\n";
|
||||
support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (!epoxy_has_gl_extension("GL_ARB_clip_control")) {
|
||||
std::cout << "Error: The OpenGL implementation doesn't support ARB_clip_control\n";
|
||||
support_level = GPU_SUPPORT_LEVEL_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute shaders have some issues with those versions (see #94936). */
|
||||
@@ -373,15 +391,9 @@ static void detect_workarounds()
|
||||
GLContext::multi_bind_support = false;
|
||||
GLContext::multi_bind_image_support = false;
|
||||
/* Turn off OpenGL 4.5 features. */
|
||||
GLContext::clip_control_support = false;
|
||||
GLContext::direct_state_access_support = false;
|
||||
/* Turn off OpenGL 4.6 features. */
|
||||
GLContext::texture_filter_anisotropic_support = false;
|
||||
GCaps.shader_draw_parameters_support = false;
|
||||
GLContext::shader_draw_parameters_support = false;
|
||||
/* Although an OpenGL 4.3 feature, our implementation requires shader_draw_parameters_support.
|
||||
* NOTE: we should untangle this by checking both features for clarity. */
|
||||
GLContext::multi_draw_indirect_support = false;
|
||||
/* Turn off extensions. */
|
||||
GLContext::layered_rendering_support = false;
|
||||
/* Turn off vendor specific extensions. */
|
||||
@@ -389,7 +401,6 @@ static void detect_workarounds()
|
||||
GLContext::framebuffer_fetch_support = false;
|
||||
GLContext::texture_barrier_support = false;
|
||||
GCaps.stencil_export_support = false;
|
||||
GCaps.clip_control_support = false;
|
||||
|
||||
#if 0
|
||||
/* Do not alter OpenGL 4.3 features.
|
||||
@@ -412,7 +423,6 @@ static void detect_workarounds()
|
||||
* Radeon R5 Graphics;
|
||||
* And others... */
|
||||
GLContext::unused_fb_slot_workaround = true;
|
||||
GCaps.shader_draw_parameters_support = false;
|
||||
GCaps.broken_amd_driver = true;
|
||||
}
|
||||
/* We have issues with this specific renderer. (see #74024) */
|
||||
@@ -421,14 +431,12 @@ static void detect_workarounds()
|
||||
strstr(renderer, "AMD TAHITI")))
|
||||
{
|
||||
GLContext::unused_fb_slot_workaround = true;
|
||||
GCaps.shader_draw_parameters_support = false;
|
||||
GCaps.broken_amd_driver = true;
|
||||
}
|
||||
/* Fix slowdown on this particular driver. (see #77641) */
|
||||
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) &&
|
||||
strstr(version, "Mesa 19.3.4"))
|
||||
{
|
||||
GCaps.shader_draw_parameters_support = false;
|
||||
GCaps.broken_amd_driver = true;
|
||||
}
|
||||
/* See #82856: AMD drivers since 20.11 running on a polaris architecture doesn't support the
|
||||
@@ -491,17 +499,6 @@ static void detect_workarounds()
|
||||
GLContext::unused_fb_slot_workaround = true;
|
||||
}
|
||||
|
||||
/* Draw shader parameters are broken on Qualcomm Windows ARM64 devices
|
||||
* on Mesa version < 24.0.0 */
|
||||
if (GPU_type_matches(GPU_DEVICE_QUALCOMM, GPU_OS_WIN, GPU_DRIVER_ANY)) {
|
||||
if (strstr(version, "Mesa 20.") || strstr(version, "Mesa 21.") ||
|
||||
strstr(version, "Mesa 22.") || strstr(version, "Mesa 23."))
|
||||
{
|
||||
GCaps.shader_draw_parameters_support = false;
|
||||
GLContext::shader_draw_parameters_support = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Snapdragon X Elite devices currently have a driver bug that results in
|
||||
* eevee rendering a black cube with anything except an emission shader
|
||||
* if shader draw parameters are enabled (#122837) */
|
||||
@@ -522,10 +519,6 @@ static void detect_workarounds()
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable multi-draw if the base instance cannot be read. */
|
||||
if (GLContext::shader_draw_parameters_support == false) {
|
||||
GLContext::multi_draw_indirect_support = false;
|
||||
}
|
||||
/* Enable our own incomplete debug layer if no other is available. */
|
||||
if (GLContext::debug_layer_support == false) {
|
||||
GLContext::debug_layer_workaround = true;
|
||||
@@ -565,7 +558,6 @@ GLint GLContext::max_ssbo_binds = 0;
|
||||
|
||||
/** Extensions. */
|
||||
|
||||
bool GLContext::clip_control_support = false;
|
||||
bool GLContext::debug_layer_support = false;
|
||||
bool GLContext::direct_state_access_support = false;
|
||||
bool GLContext::explicit_location_support = false;
|
||||
@@ -574,8 +566,6 @@ bool GLContext::layered_rendering_support = false;
|
||||
bool GLContext::native_barycentric_support = false;
|
||||
bool GLContext::multi_bind_support = false;
|
||||
bool GLContext::multi_bind_image_support = false;
|
||||
bool GLContext::multi_draw_indirect_support = false;
|
||||
bool GLContext::shader_draw_parameters_support = false;
|
||||
bool GLContext::stencil_texturing_support = false;
|
||||
bool GLContext::texture_barrier_support = false;
|
||||
bool GLContext::texture_filter_anisotropic_support = false;
|
||||
@@ -610,7 +600,6 @@ void GLBackend::capabilities_init()
|
||||
GCaps.max_samplers = GCaps.max_textures;
|
||||
GCaps.mem_stats_support = epoxy_has_gl_extension("GL_NVX_gpu_memory_info") ||
|
||||
epoxy_has_gl_extension("GL_ATI_meminfo");
|
||||
GCaps.shader_draw_parameters_support = epoxy_has_gl_extension("GL_ARB_shader_draw_parameters");
|
||||
GCaps.geometry_shader_support = true;
|
||||
GCaps.max_samplers = GCaps.max_textures;
|
||||
GCaps.hdr_viewport_support = false;
|
||||
@@ -658,15 +647,9 @@ void GLBackend::capabilities_init()
|
||||
"GL_AMD_shader_explicit_vertex_parameter");
|
||||
GLContext::multi_bind_support = GLContext::multi_bind_image_support = epoxy_has_gl_extension(
|
||||
"GL_ARB_multi_bind");
|
||||
GLContext::multi_draw_indirect_support = epoxy_has_gl_extension("GL_ARB_multi_draw_indirect");
|
||||
GLContext::shader_draw_parameters_support = epoxy_has_gl_extension(
|
||||
"GL_ARB_shader_draw_parameters");
|
||||
GLContext::stencil_texturing_support = epoxy_gl_version() >= 43;
|
||||
GLContext::texture_filter_anisotropic_support = epoxy_has_gl_extension(
|
||||
"GL_EXT_texture_filter_anisotropic");
|
||||
GLContext::clip_control_support = epoxy_has_gl_extension("GL_ARB_clip_control");
|
||||
|
||||
GCaps.clip_control_support = GLContext::clip_control_support;
|
||||
|
||||
/* Disabled until it is proven to work. */
|
||||
GLContext::framebuffer_fetch_support = false;
|
||||
|
||||
@@ -48,7 +48,6 @@ class GLContext : public Context {
|
||||
|
||||
/** Extensions. */
|
||||
|
||||
static bool clip_control_support;
|
||||
static bool debug_layer_support;
|
||||
static bool direct_state_access_support;
|
||||
static bool explicit_location_support;
|
||||
@@ -57,8 +56,6 @@ class GLContext : public Context {
|
||||
static bool native_barycentric_support;
|
||||
static bool multi_bind_support;
|
||||
static bool multi_bind_image_support;
|
||||
static bool multi_draw_indirect_support;
|
||||
static bool shader_draw_parameters_support;
|
||||
static bool stencil_texturing_support;
|
||||
static bool texture_barrier_support;
|
||||
static bool texture_filter_anisotropic_support;
|
||||
|
||||
@@ -757,7 +757,7 @@ std::string GLShader::vertex_interface_declare(const ShaderCreateInfo &info) con
|
||||
}
|
||||
}
|
||||
if (bool(info.builtins_ & BuiltinBits::CLIP_CONTROL)) {
|
||||
if (GLContext::clip_control_support && !has_geometry_stage) {
|
||||
if (!has_geometry_stage) {
|
||||
/* Assume clip range is set to 0..1 and remap the range just like Vulkan and Metal.
|
||||
* If geometry stage is needed, do that remapping inside the geometry shader stage. */
|
||||
post_main += "gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n";
|
||||
@@ -1033,10 +1033,8 @@ std::string GLShader::workaround_geometry_shader_source_create(
|
||||
}
|
||||
ss << " gl_Position = gl_in[" << i << "].gl_Position;\n";
|
||||
if (bool(info.builtins_ & BuiltinBits::CLIP_CONTROL)) {
|
||||
if (GLContext::clip_control_support) {
|
||||
/* Assume clip range is set to 0..1 and remap the range just like Vulkan and Metal. */
|
||||
ss << "gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n";
|
||||
}
|
||||
/* Assume clip range is set to 0..1 and remap the range just like Vulkan and Metal. */
|
||||
ss << "gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n";
|
||||
}
|
||||
if (do_layer_output) {
|
||||
ss << " gl_Layer = gpu_Layer[" << i << "];\n";
|
||||
@@ -1081,10 +1079,12 @@ static StringRefNull glsl_patch_vertex_get()
|
||||
|
||||
/* Enable extensions for features that are not part of our base GLSL version
|
||||
* don't use an extension for something already available! */
|
||||
if (GLContext::shader_draw_parameters_support) {
|
||||
{
|
||||
/* Required extension. */
|
||||
ss << "#extension GL_ARB_shader_draw_parameters : enable\n";
|
||||
ss << "#define GPU_ARB_shader_draw_parameters\n";
|
||||
ss << "#define gpu_BaseInstance gl_BaseInstanceARB\n";
|
||||
ss << "#define GPU_ARB_clip_control\n";
|
||||
}
|
||||
if (GLContext::layered_rendering_support) {
|
||||
ss << "#extension GL_ARB_shader_viewport_layer_array: enable\n";
|
||||
@@ -1092,14 +1092,6 @@ static StringRefNull glsl_patch_vertex_get()
|
||||
if (GLContext::native_barycentric_support) {
|
||||
ss << "#extension GL_AMD_shader_explicit_vertex_parameter: enable\n";
|
||||
}
|
||||
if (GLContext::clip_control_support) {
|
||||
ss << "#define GPU_ARB_clip_control\n";
|
||||
}
|
||||
|
||||
/* Fallbacks. */
|
||||
if (!GLContext::shader_draw_parameters_support) {
|
||||
ss << "uniform int gpu_BaseInstance;\n";
|
||||
}
|
||||
|
||||
/* Vulkan GLSL compatibility. */
|
||||
ss << "#define gpu_InstanceIndex (gl_InstanceID + gpu_BaseInstance)\n";
|
||||
@@ -1131,9 +1123,7 @@ static StringRefNull glsl_patch_geometry_get()
|
||||
if (GLContext::native_barycentric_support) {
|
||||
ss << "#extension GL_AMD_shader_explicit_vertex_parameter: enable\n";
|
||||
}
|
||||
if (GLContext::clip_control_support) {
|
||||
ss << "#define GPU_ARB_clip_control\n";
|
||||
}
|
||||
ss << "#define GPU_ARB_clip_control\n";
|
||||
|
||||
/* Array compatibility. */
|
||||
ss << "#define gpu_Array(_type) _type[]\n";
|
||||
@@ -1169,9 +1159,7 @@ static StringRefNull glsl_patch_fragment_get()
|
||||
ss << "#extension GL_ARB_shader_stencil_export: enable\n";
|
||||
ss << "#define GPU_ARB_shader_stencil_export\n";
|
||||
}
|
||||
if (GLContext::clip_control_support) {
|
||||
ss << "#define GPU_ARB_clip_control\n";
|
||||
}
|
||||
ss << "#define GPU_ARB_clip_control\n";
|
||||
|
||||
/* Array compatibility. */
|
||||
ss << "#define gpu_Array(_type) _type[]\n";
|
||||
@@ -1200,9 +1188,7 @@ static StringRefNull glsl_patch_compute_get()
|
||||
/* Needs to have this defined upfront for configuring shader defines. */
|
||||
ss << "#define GPU_COMPUTE_SHADER\n";
|
||||
|
||||
if (GLContext::clip_control_support) {
|
||||
ss << "#define GPU_ARB_clip_control\n";
|
||||
}
|
||||
ss << "#define GPU_ARB_clip_control\n";
|
||||
|
||||
ss << datatoc_glsl_shader_defines_glsl;
|
||||
|
||||
|
||||
@@ -413,28 +413,13 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI
|
||||
}
|
||||
}
|
||||
|
||||
size_t workaround_names_size = 0;
|
||||
Vector<StringRefNull> workaround_uniform_names;
|
||||
auto check_enabled_uniform = [&](const char *uniform_name) {
|
||||
if (glGetUniformLocation(program, uniform_name) != -1) {
|
||||
workaround_uniform_names.append(uniform_name);
|
||||
workaround_names_size += StringRefNull(uniform_name).size() + 1;
|
||||
uniform_len_++;
|
||||
}
|
||||
};
|
||||
|
||||
if (!GLContext::shader_draw_parameters_support) {
|
||||
check_enabled_uniform("gpu_BaseInstance");
|
||||
}
|
||||
|
||||
BLI_assert_msg(ubo_len_ <= 16, "enabled_ubo_mask_ is uint16_t");
|
||||
|
||||
int input_tot_len = attr_len_ + ubo_len_ + uniform_len_ + ssbo_len_ + constant_len_;
|
||||
inputs_ = MEM_calloc_arrayN<ShaderInput>(input_tot_len, __func__);
|
||||
ShaderInput *input = inputs_;
|
||||
|
||||
name_buffer_ = (char *)MEM_mallocN(info.interface_names_size_ + workaround_names_size,
|
||||
"name_buffer");
|
||||
name_buffer_ = (char *)MEM_mallocN(info.interface_names_size_, "name_buffer");
|
||||
uint32_t name_buffer_offset = 0;
|
||||
|
||||
/* Necessary to make #glUniform works. TODO(fclem) Remove. */
|
||||
@@ -509,14 +494,6 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI
|
||||
input++;
|
||||
}
|
||||
|
||||
/* Compatibility uniforms. */
|
||||
for (auto &name : workaround_uniform_names) {
|
||||
copy_input_name(input, name, name_buffer_, name_buffer_offset);
|
||||
input->location = glGetUniformLocation(program, name_buffer_ + input->name_offset);
|
||||
input->binding = -1;
|
||||
input++;
|
||||
}
|
||||
|
||||
/* SSBOs */
|
||||
for (const ShaderCreateInfo::Resource &res : all_resources) {
|
||||
if (res.bind_type == ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER) {
|
||||
|
||||
@@ -334,14 +334,12 @@ void GLStateManager::set_shadow_bias(const bool enable)
|
||||
|
||||
void GLStateManager::set_clip_control(const bool enable)
|
||||
{
|
||||
if (GLContext::clip_control_support) {
|
||||
if (enable) {
|
||||
/* Match Vulkan and Metal by default. */
|
||||
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||
}
|
||||
else {
|
||||
glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
|
||||
}
|
||||
if (enable) {
|
||||
/* Match Vulkan and Metal by default. */
|
||||
glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE);
|
||||
}
|
||||
else {
|
||||
glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,24 +106,6 @@ void GLVertArray::update_bindings(const GLuint vao,
|
||||
}
|
||||
}
|
||||
|
||||
if (batch->resource_id_buf) {
|
||||
const ShaderInput *input = interface->attr_get("in_resource_id");
|
||||
int component_len = 1;
|
||||
if (input == nullptr) {
|
||||
/* Uses Custom IDs */
|
||||
input = interface->attr_get("in_resource_id_custom_id");
|
||||
component_len = 2;
|
||||
}
|
||||
if (input) {
|
||||
dynamic_cast<GLStorageBuf *>(batch->resource_id_buf)->bind_as(GL_ARRAY_BUFFER);
|
||||
glEnableVertexAttribArray(input->location);
|
||||
glVertexAttribDivisor(input->location, 1);
|
||||
glVertexAttribIPointer(
|
||||
input->location, component_len, to_gl(GPU_COMP_U32), 0, (GLvoid *)nullptr);
|
||||
attr_mask &= ~(1 << input->location);
|
||||
}
|
||||
}
|
||||
|
||||
if (attr_mask != 0) {
|
||||
for (uint16_t mask = 1, a = 0; a < 16; a++, mask <<= 1) {
|
||||
if (attr_mask & mask) {
|
||||
|
||||
@@ -119,8 +119,10 @@ static Vector<StringRefNull> missing_capabilities_get(VkPhysicalDevice vk_physic
|
||||
/* Check device features. */
|
||||
VkPhysicalDeviceVulkan12Features features_12 = {
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES};
|
||||
VkPhysicalDeviceVulkan11Features features_11 = {
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES, &features_12};
|
||||
VkPhysicalDeviceFeatures2 features = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||
&features_12};
|
||||
&features_11};
|
||||
|
||||
vkGetPhysicalDeviceFeatures2(vk_physical_device, &features);
|
||||
|
||||
@@ -153,6 +155,9 @@ static Vector<StringRefNull> missing_capabilities_get(VkPhysicalDevice vk_physic
|
||||
if (features.features.fragmentStoresAndAtomics == VK_FALSE) {
|
||||
missing_capabilities.append("fragment stores and atomics");
|
||||
}
|
||||
if (features_11.shaderDrawParameters == VK_FALSE) {
|
||||
missing_capabilities.append("shader draw parameters");
|
||||
}
|
||||
if (features_12.timelineSemaphore == VK_FALSE) {
|
||||
missing_capabilities.append("timeline semaphores");
|
||||
}
|
||||
@@ -706,11 +711,8 @@ void VKBackend::capabilities_init(VKDevice &device)
|
||||
/* Reset all capabilities from previous context. */
|
||||
GCaps = {};
|
||||
GCaps.geometry_shader_support = true;
|
||||
GCaps.clip_control_support = true;
|
||||
GCaps.stencil_export_support = device.supports_extension(
|
||||
VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME);
|
||||
GCaps.shader_draw_parameters_support =
|
||||
device.physical_device_vulkan_11_features_get().shaderDrawParameters;
|
||||
|
||||
GCaps.max_texture_size = max_ii(limits.maxImageDimension1D, limits.maxImageDimension2D);
|
||||
GCaps.max_texture_3d_size = min_uu(limits.maxImageDimension3D, INT_MAX);
|
||||
|
||||
@@ -339,7 +339,8 @@ void VKDevice::init_glsl_patch()
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "#version 450\n";
|
||||
if (GPU_shader_draw_parameters_support()) {
|
||||
{
|
||||
/* Required extension. */
|
||||
ss << "#extension GL_ARB_shader_draw_parameters : enable\n";
|
||||
ss << "#define GPU_ARB_shader_draw_parameters\n";
|
||||
ss << "#define gpu_BaseInstance (gl_BaseInstanceARB)\n";
|
||||
|
||||
Reference in New Issue
Block a user