WIP: Vulkan: Workbench #107886
|
@ -72,6 +72,16 @@ void VKBackend::platform_init(const VKDevice &device)
|
|||
driver_version.c_str());
|
||||
}
|
||||
|
||||
void VKBackend::detect_workarounds(VKDevice &device)
|
||||
{
|
||||
device.workarounds_.depth_component_24 = false;
|
||||
|
||||
/* */
|
||||
if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) {
|
||||
device.workarounds_.depth_component_24 = true;
|
||||
}
|
||||
}
|
||||
|
||||
void VKBackend::platform_exit()
|
||||
{
|
||||
GPG.clear();
|
||||
|
@ -173,7 +183,7 @@ shaderc::Compiler &VKBackend::get_shaderc_compiler()
|
|||
return shaderc_compiler_;
|
||||
}
|
||||
|
||||
void VKBackend::capabilities_init(const VKDevice &device)
|
||||
void VKBackend::capabilities_init(VKDevice &device)
|
||||
{
|
||||
const VkPhysicalDeviceProperties &properties = device.physical_device_properties_get();
|
||||
const VkPhysicalDeviceLimits &limits = properties.limits;
|
||||
|
@ -204,6 +214,8 @@ void VKBackend::capabilities_init(const VKDevice &device)
|
|||
GCaps.max_varying_floats = limits.maxVertexOutputComponents;
|
||||
GCaps.max_shader_storage_buffer_bindings = limits.maxPerStageDescriptorStorageBuffers;
|
||||
GCaps.max_compute_shader_storage_blocks = limits.maxPerStageDescriptorStorageBuffers;
|
||||
|
||||
detect_workarounds(device);
|
||||
}
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
|
|
@ -87,9 +87,10 @@ class VKBackend : public GPUBackend {
|
|||
}
|
||||
|
||||
static void platform_init(const VKDevice &device);
|
||||
static void capabilities_init(const VKDevice &device);
|
||||
static void capabilities_init(VKDevice &device);
|
||||
|
||||
private:
|
||||
static void detect_workarounds(VKDevice &device);
|
||||
static void platform_init();
|
||||
static void platform_exit();
|
||||
|
||||
|
|
|
@ -211,4 +211,5 @@ void VKContext::bind_graphics_pipeline(const GPUPrimType prim_type,
|
|||
|
||||
/** \} */
|
||||
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
|
|
@ -25,6 +25,9 @@ class VKContext : public Context, NonCopyable {
|
|||
|
||||
void *ghost_context_;
|
||||
|
||||
/** Workarounds. */
|
||||
static bool component_24_workaround;
|
||||
|
||||
public:
|
||||
VKContext(void *ghost_window, void *ghost_context);
|
||||
virtual ~VKContext();
|
||||
|
@ -69,6 +72,8 @@ class VKContext : public Context, NonCopyable {
|
|||
|
||||
const VKStateManager &state_manager_get() const;
|
||||
VKStateManager &state_manager_get();
|
||||
|
||||
static bool get_component_24_workaround();
|
||||
};
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
|
|
@ -87,7 +87,8 @@ void VKDevice::init_descriptor_pools()
|
|||
|
||||
constexpr int32_t PCI_ID_NVIDIA = 0x10de;
|
||||
constexpr int32_t PCI_ID_INTEL = 0x8086;
|
||||
constexpr int32_t PCI_ID_AMD = 0x1022;
|
||||
constexpr int32_t PCI_ID_AMD = 0x1002;
|
||||
constexpr int32_t PCI_ID_ATI = 0x1022;
|
||||
|
||||
eGPUDeviceType VKDevice::device_type() const
|
||||
{
|
||||
|
@ -103,6 +104,7 @@ eGPUDeviceType VKDevice::device_type() const
|
|||
case PCI_ID_INTEL:
|
||||
return GPU_DEVICE_INTEL;
|
||||
case PCI_ID_AMD:
|
||||
case PCI_ID_ATI:
|
||||
return GPU_DEVICE_ATI;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "vk_descriptor_pools.hh"
|
||||
|
||||
namespace blender::gpu {
|
||||
class VKBackend;
|
||||
|
||||
class VKDevice : public NonCopyable {
|
||||
private:
|
||||
|
@ -34,6 +35,12 @@ class VKDevice : public NonCopyable {
|
|||
/** Functions of vk_ext_debugutils for this device/instance. */
|
||||
debug::VKDebuggingTools debugging_tools_;
|
||||
|
||||
/* Workarounds */
|
||||
struct {
|
||||
bool depth_component_24 = false;
|
||||
|
||||
} workarounds_;
|
||||
|
||||
public:
|
||||
VkPhysicalDevice physical_device_get() const
|
||||
{
|
||||
|
@ -94,11 +101,24 @@ class VKDevice : public NonCopyable {
|
|||
std::string vendor_name() const;
|
||||
std::string driver_version() const;
|
||||
|
||||
/**
|
||||
* Some devices don't support `GPU_DEPTH_COMPONENT_24` texture formats.
|
||||
*
|
||||
* Check with this function if the workaround should be used to work around this issue.
|
||||
*/
|
||||
bool get_component_24_workaround() const
|
||||
{
|
||||
return workarounds_.depth_component_24;
|
||||
}
|
||||
|
||||
private:
|
||||
void init_physical_device_properties();
|
||||
void init_debug_callbacks();
|
||||
void init_memory_allocator();
|
||||
void init_descriptor_pools();
|
||||
|
||||
/* During initialization the backend requires access to update the workarounds. */
|
||||
friend VKBackend;
|
||||
};
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
|
|
@ -218,6 +218,14 @@ bool VKTexture::init_internal()
|
|||
* at this moment, so we cannot initialize here. The initialization is postponed until the
|
||||
* allocation of the texture on the device. */
|
||||
|
||||
const VKDevice &device = VKBackend::get().device_get();
|
||||
if (format_ == GPU_DEPTH_COMPONENT24 && device.get_component_24_workaround()) {
|
||||
format_ = GPU_DEPTH_COMPONENT32F;
|
||||
}
|
||||
if (format_ == GPU_DEPTH24_STENCIL8 && device.get_component_24_workaround()) {
|
||||
format_ = GPU_DEPTH32F_STENCIL8;
|
||||
}
|
||||
|
||||
/* TODO: return false when texture format isn't supported. */
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue