[Bf-blender-cvs] [5ca4e9e5451] temp-vulkan-shader: Added other stages to VKShader.
Jeroen Bakker
noreply at git.blender.org
Fri Nov 25 10:05:02 CET 2022
Commit: 5ca4e9e5451f458df7731565291d3578e1129ee5
Author: Jeroen Bakker
Date: Fri Nov 25 10:03:10 2022 +0100
Branches: temp-vulkan-shader
https://developer.blender.org/rB5ca4e9e5451f458df7731565291d3578e1129ee5
Added other stages to VKShader.
===================================================================
M source/blender/gpu/intern/gpu_shader_builder.cc
M source/blender/gpu/vulkan/vk_shader.cc
M source/blender/gpu/vulkan/vk_shader.hh
===================================================================
diff --git a/source/blender/gpu/intern/gpu_shader_builder.cc b/source/blender/gpu/intern/gpu_shader_builder.cc
index 877cd1ee406..2a573072249 100644
--- a/source/blender/gpu/intern/gpu_shader_builder.cc
+++ b/source/blender/gpu/intern/gpu_shader_builder.cc
@@ -103,9 +103,9 @@ int main(int argc, const char *argv[])
};
blender::Vector<NamedBackend> backends_to_validate;
- backends_to_validate.append({"OpenGL", GPU_BACKEND_OPENGL});
+ //backends_to_validate.append({"OpenGL", GPU_BACKEND_OPENGL});
#ifdef WITH_METAL_BACKEND
- backends_to_validate.append({"Metal", GPU_BACKEND_METAL});
+ //backends_to_validate.append({"Metal", GPU_BACKEND_METAL});
#endif
#ifdef WITH_VULKAN_BACKEND
backends_to_validate.append({"Vulkan", GPU_BACKEND_VULKAN});
diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc
index 6067c5e1653..43b99882ff0 100644
--- a/source/blender/gpu/vulkan/vk_shader.cc
+++ b/source/blender/gpu/vulkan/vk_shader.cc
@@ -18,6 +18,12 @@ namespace blender::gpu {
static const std::string to_stage_name(shaderc_shader_kind stage)
{
switch (stage) {
+ case shaderc_vertex_shader:
+ return std::string("vertex");
+ case shaderc_geometry_shader:
+ return std::string("geometry");
+ case shaderc_fragment_shader:
+ return std::string("fragment");
case shaderc_compute_shader:
return std::string("compute");
@@ -98,6 +104,7 @@ VKShader::VKShader(const char *name) : Shader(name)
{
context_ = VKContext::get();
}
+
VKShader::~VKShader()
{
VkDevice device = context_->device_get();
@@ -111,23 +118,30 @@ void VKShader::build_shader_module(MutableSpan<const char *> sources,
shaderc_shader_kind stage,
VkShaderModule *r_shader_module)
{
- BLI_assert_msg(ELEM(stage, shaderc_compute_shader),
+ BLI_assert_msg(ELEM(stage,
+ shaderc_vertex_shader,
+ shaderc_geometry_shader,
+ shaderc_fragment_shader,
+ shaderc_compute_shader),
"Only forced ShaderC shader kinds are supported.");
sources[0] = glsl_patch_get();
Vector<uint32_t> spirv_module = compile_glsl_to_spirv(sources, shaderc_compute_shader);
build_shader_module(spirv_module, &compute_module_);
}
-void VKShader::vertex_shader_from_glsl(MutableSpan<const char *> /*sources*/)
+void VKShader::vertex_shader_from_glsl(MutableSpan<const char *> sources)
{
+ build_shader_module(sources, shaderc_vertex_shader, &vertex_module_);
}
-void VKShader::geometry_shader_from_glsl(MutableSpan<const char *> /*sources*/)
+void VKShader::geometry_shader_from_glsl(MutableSpan<const char *> sources)
{
+ build_shader_module(sources, shaderc_geometry_shader, &geometry_module_);
}
-void VKShader::fragment_shader_from_glsl(MutableSpan<const char *> /*sources*/)
+void VKShader::fragment_shader_from_glsl(MutableSpan<const char *> sources)
{
+ build_shader_module(sources, shaderc_fragment_shader, &fragment_module_);
}
void VKShader::compute_shader_from_glsl(MutableSpan<const char *> sources)
diff --git a/source/blender/gpu/vulkan/vk_shader.hh b/source/blender/gpu/vulkan/vk_shader.hh
index f1cd25245da..cc4963ac7d5 100644
--- a/source/blender/gpu/vulkan/vk_shader.hh
+++ b/source/blender/gpu/vulkan/vk_shader.hh
@@ -19,7 +19,10 @@ namespace blender::gpu {
class VKShader : public Shader {
private:
VKContext *context_ = nullptr;
- VkShaderModule compute_module_ = nullptr;
+ VkShaderModule vertex_module_ = VK_NULL_HANDLE;
+ VkShaderModule geometry_module_ = VK_NULL_HANDLE;
+ VkShaderModule fragment_module_ = VK_NULL_HANDLE;
+ VkShaderModule compute_module_ = VK_NULL_HANDLE;
public:
VKShader(const char *name);
More information about the Bf-blender-cvs
mailing list