diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-03-31 13:45:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 13:45:43 +0200 |
commit | 9cd1e5096993e6b2fc92da098e3ab1ca19f40b07 (patch) | |
tree | 6d416aff668a75acc79652fb7519b925dea9b0e0 /servers | |
parent | 6b25c94bd62a92a82551bf0aa03343bc2b3c3c7b (diff) | |
parent | e93c9fc4ed0e411a9c3ccc33e47d7dbfaf4abeb8 (diff) |
Merge pull request #47250 from BastiaanOlij/check_vulkan_version
Obtain supported Vulkan API
Diffstat (limited to 'servers')
5 files changed, 38 insertions, 5 deletions
diff --git a/servers/rendering/renderer_rd/shaders/cluster_render.glsl b/servers/rendering/renderer_rd/shaders/cluster_render.glsl index 8723ea78e4..ca92d2104e 100644 --- a/servers/rendering/renderer_rd/shaders/cluster_render.glsl +++ b/servers/rendering/renderer_rd/shaders/cluster_render.glsl @@ -65,7 +65,7 @@ void main() { VERSION_DEFINES -#if defined(GL_KHR_shader_subgroup_ballot) && defined(GL_KHR_shader_subgroup_arithmetic) && defined(GL_KHR_shader_subgroup_vote) +#if defined(has_GL_KHR_shader_subgroup_ballot) && defined(has_GL_KHR_shader_subgroup_arithmetic) && defined(has_GL_KHR_shader_subgroup_vote) #extension GL_KHR_shader_subgroup_ballot : enable #extension GL_KHR_shader_subgroup_arithmetic : enable diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl index d78890fa9e..4ea05c9ccc 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl @@ -3,7 +3,7 @@ #define MAX_GI_PROBES 8 -#if defined(GL_KHR_shader_subgroup_ballot) && defined(GL_KHR_shader_subgroup_arithmetic) +#if defined(has_GL_KHR_shader_subgroup_ballot) && defined(has_GL_KHR_shader_subgroup_arithmetic) #extension GL_KHR_shader_subgroup_ballot : enable #extension GL_KHR_shader_subgroup_arithmetic : enable diff --git a/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl b/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl index e7ba8feb80..ce8a459b24 100644 --- a/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl +++ b/servers/rendering/renderer_rd/shaders/volumetric_fog.glsl @@ -5,10 +5,10 @@ VERSION_DEFINES /* Do not use subgroups here, seems there is not much advantage and causes glitches +#if defined(has_GL_KHR_shader_subgroup_ballot) && defined(has_GL_KHR_shader_subgroup_arithmetic) #extension GL_KHR_shader_subgroup_ballot: enable #extension GL_KHR_shader_subgroup_arithmetic: enable -#if defined(GL_KHR_shader_subgroup_ballot) && defined(GL_KHR_shader_subgroup_arithmetic) #define USE_SUBGROUPS #endif */ diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 27a9353e4e..e6ad001807 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -59,7 +59,7 @@ Vector<uint8_t> RenderingDevice::shader_compile_from_source(ShaderStage p_stage, ERR_FAIL_COND_V(!compile_function, Vector<uint8_t>()); - return compile_function(p_stage, p_source_code, p_language, r_error); + return compile_function(p_stage, p_source_code, p_language, r_error, &device_capabilities); } RID RenderingDevice::_texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const TypedArray<PackedByteArray> &p_data) { diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 9fbf58d131..2de0549e8d 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -51,6 +51,13 @@ class RDPipelineColorBlendState; class RenderingDevice : public Object { GDCLASS(RenderingDevice, Object) public: + enum DeviceFamily { + DEVICE_UNKNOWN, + DEVICE_OPENGL, + DEVICE_VULKAN, + DEVICE_DIRECTX + }; + enum ShaderStage { SHADER_STAGE_VERTEX, SHADER_STAGE_FRAGMENT, @@ -70,7 +77,29 @@ public: SHADER_LANGUAGE_HLSL }; - typedef Vector<uint8_t> (*ShaderCompileFunction)(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language, String *r_error); + enum SubgroupOperations { + SUBGROUP_BASIC_BIT = 1, + SUBGROUP_VOTE_BIT = 2, + SUBGROUP_ARITHMETIC_BIT = 4, + SUBGROUP_BALLOT_BIT = 8, + SUBGROUP_SHUFFLE_BIT = 16, + SUBGROUP_SHUFFLE_RELATIVE_BIT = 32, + SUBGROUP_CLUSTERED_BIT = 64, + SUBGROUP_QUAD_BIT = 128, + }; + + struct Capabilities { + // main device info + DeviceFamily device_family = DEVICE_UNKNOWN; + uint32_t version_major = 1.0; + uint32_t version_minor = 0.0; + // subgroup capabilities + uint32_t subgroup_size = 0; + uint32_t subgroup_in_shaders = 0; // Set flags using SHADER_STAGE_VERTEX_BIT, SHADER_STAGE_FRAGMENT_BIT, etc. + uint32_t subgroup_operations = 0; // Set flags, using SubgroupOperations + }; + + typedef Vector<uint8_t> (*ShaderCompileFunction)(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language, String *r_error, const Capabilities *p_capabilities); typedef Vector<uint8_t> (*ShaderCacheFunction)(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language); private: @@ -82,6 +111,8 @@ private: protected: static void _bind_methods(); + Capabilities device_capabilities; + public: //base numeric ID for all types enum { @@ -597,6 +628,8 @@ public: /**** SHADER ****/ /****************/ + const Capabilities *get_device_capabilities() const { return &device_capabilities; }; + virtual Vector<uint8_t> shader_compile_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language = SHADER_LANGUAGE_GLSL, String *r_error = nullptr, bool p_allow_cache = true); static void shader_set_compile_function(ShaderCompileFunction p_function); |