diff --git a/drivers/metal/rendering_device_driver_metal.h b/drivers/metal/rendering_device_driver_metal.h index 09ab7601e9c1..7c6b7a4cae9c 100644 --- a/drivers/metal/rendering_device_driver_metal.h +++ b/drivers/metal/rendering_device_driver_metal.h @@ -380,6 +380,24 @@ class API_AVAILABLE(macos(11.0), ios(14.0)) RenderingDeviceDriverMetal : public virtual PipelineID compute_pipeline_create(ShaderID p_shader, VectorView p_specialization_constants) override final; +#pragma mark - Raytracing + + virtual RDD::AccelerationStructureID blas_create(BufferID p_vertex_buffer, uint64_t p_vertex_offset, VertexFormatID p_vertex_format, uint32_t p_vertex_count, BufferID p_index_buffer, IndexBufferFormat p_index_format, uint64_t p_index_offset_bytes, uint32_t p_index_count, BufferID p_transform_buffer, uint64_t p_transform_offset) override final; + virtual RDD::AccelerationStructureID tlas_create(const LocalVector &p_blases) override final; + virtual void acceleration_structure_free(AccelerationStructureID p_acceleration_structure) override final; + + // ----- PIPELINE ----- + + virtual RaytracingPipelineID raytracing_pipeline_create(ShaderID p_shader, VectorView p_specialization_constants) override final; + virtual void raytracing_pipeline_free(RDD::RaytracingPipelineID p_pipeline) override final; + + // ----- COMMANDS ----- + + virtual void command_build_acceleration_structure(CommandBufferID p_cmd_buffer, AccelerationStructureID p_acceleration_structure) override final; + virtual void command_bind_raytracing_pipeline(CommandBufferID p_cmd_buffer, RaytracingPipelineID p_pipeline) override final; + virtual void command_bind_raytracing_uniform_set(CommandBufferID p_cmd_buffer, UniformSetID p_uniform_set, ShaderID p_shader, uint32_t p_set_index) override final; + virtual void command_raytracing_trace_rays(CommandBufferID p_cmd_buffer, RaytracingPipelineID p_pipeline, ShaderID p_shader, uint32_t p_width, uint32_t p_height) override final; + #pragma mark - Queries // ----- TIMESTAMP ----- diff --git a/drivers/metal/rendering_device_driver_metal.mm b/drivers/metal/rendering_device_driver_metal.mm index 784c9d5ae8aa..cb0cf8cbff7c 100644 --- a/drivers/metal/rendering_device_driver_metal.mm +++ b/drivers/metal/rendering_device_driver_metal.mm @@ -1517,7 +1517,7 @@ struct API_AVAILABLE(macos(11.0), ios(14.0)) ShaderBinaryData { uint32_t vertex_input_mask = UINT32_MAX; uint32_t fragment_output_mask = UINT32_MAX; uint32_t spirv_specialization_constants_ids_mask = UINT32_MAX; - uint32_t is_compute = UINT32_MAX; + uint32_t pipeline_type = (uint32_t)RenderingDevice::PipelineType::RASTERIZATION; uint32_t needs_view_mask_buffer = UINT32_MAX; ComputeSize compute_local_size; PushConstantData push_constant; @@ -1538,7 +1538,7 @@ size_t serialize_size() const { size += sizeof(uint32_t); // vertex_input_mask size += sizeof(uint32_t); // fragment_output_mask size += sizeof(uint32_t); // spirv_specialization_constants_ids_mask - size += sizeof(uint32_t); // is_compute + size += sizeof(uint32_t); // pipeline_type size += sizeof(uint32_t); // needs_view_mask_buffer size += compute_local_size.serialize_size(); // compute_local_size size += push_constant.serialize_size(); // push_constant @@ -1563,7 +1563,7 @@ void serialize(BufWriter &p_writer) const { p_writer.write(vertex_input_mask); p_writer.write(fragment_output_mask); p_writer.write(spirv_specialization_constants_ids_mask); - p_writer.write(is_compute); + p_writer.write(pipeline_type); p_writer.write(needs_view_mask_buffer); p_writer.write(compute_local_size); p_writer.write(push_constant); @@ -1578,7 +1578,7 @@ void deserialize(BufReader &p_reader) { p_reader.read(vertex_input_mask); p_reader.read(fragment_output_mask); p_reader.read(spirv_specialization_constants_ids_mask); - p_reader.read(is_compute); + p_reader.read(pipeline_type); p_reader.read(needs_view_mask_buffer); p_reader.read(compute_local_size); p_reader.read(push_constant); @@ -1617,10 +1617,14 @@ void deserialize(BufReader &p_reader) { ShaderStage stage_flag = (ShaderStage)(1 << p_spirv[i].shader_stage); if (p_spirv[i].shader_stage == SHADER_STAGE_COMPUTE) { - r_reflection.is_compute = true; + r_reflection.pipeline_type = PipelineType::COMPUTE; ERR_FAIL_COND_V_MSG(p_spirv.size() != 1, FAILED, "Compute shaders can only receive one stage, dedicated to compute."); } + if (p_spirv[i].shader_stage == SHADER_STAGE_RAYGEN || p_spirv[i].shader_stage == SHADER_STAGE_MISS || p_spirv[i].shader_stage == SHADER_STAGE_CLOSEST_HIT) { + r_reflection.pipeline_type = PipelineType::RAYTRACING; + } + ERR_FAIL_COND_V_MSG(r_reflection.stages.has_flag(stage_flag), FAILED, "Stage " + String(SHADER_STAGE_NAMES[p_spirv[i].shader_stage]) + " submitted more than once."); @@ -1629,7 +1633,7 @@ void deserialize(BufReader &p_reader) { Compiler compiler(std::move(pir)); - if (r_reflection.is_compute) { + if (r_reflection.pipeline_type == PipelineType::COMPUTE) { r_reflection.compute_local_size[0] = compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 0); r_reflection.compute_local_size[1] = compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 1); r_reflection.compute_local_size[2] = compiler.get_execution_mode_argument(spv::ExecutionModeLocalSize, 2); @@ -1926,7 +1930,7 @@ void deserialize(BufReader &p_reader) { .y = spirv_data.compute_local_size[1], .z = spirv_data.compute_local_size[2], }; - bin_data.is_compute = spirv_data.is_compute; + bin_data.pipeline_type = (uint32_t)spirv_data.pipeline_type; bin_data.push_constant.size = spirv_data.push_constant_size; bin_data.push_constant.stages = (ShaderStageUsage)(uint8_t)spirv_data.push_constant_stages; bin_data.needs_view_mask_buffer = shader_meta.has_multiview ? 1 : 0; @@ -2479,7 +2483,7 @@ void deserialize(BufReader &p_reader) { } MDShader *shader = nullptr; - if (binary_data.is_compute) { + if (binary_data.pipeline_type == (uint32_t)PipelineType::COMPUTE) { MDComputeShader *cs = new MDComputeShader(binary_data.shader_name, uniform_sets, libraries[ShaderStage::SHADER_STAGE_COMPUTE]); uint32_t *binding = binary_data.push_constant.msl_binding.getptr(SHADER_STAGE_COMPUTE); @@ -2521,7 +2525,7 @@ void deserialize(BufReader &p_reader) { r_shader_desc.vertex_input_mask = binary_data.vertex_input_mask; r_shader_desc.fragment_output_mask = binary_data.fragment_output_mask; - r_shader_desc.is_compute = binary_data.is_compute; + r_shader_desc.pipeline_type = (RenderingDevice::PipelineType)binary_data.pipeline_type; r_shader_desc.compute_local_size[0] = binary_data.compute_local_size.x; r_shader_desc.compute_local_size[1] = binary_data.compute_local_size.y; r_shader_desc.compute_local_size[2] = binary_data.compute_local_size.z; @@ -3624,6 +3628,51 @@ bool isArrayTexture(MTLTextureType p_type) { return PipelineID(pipeline); } +#pragma mark - Raytracing + +RDD::AccelerationStructureID RenderingDeviceDriverMetal::blas_create(BufferID p_vertex_buffer, uint64_t p_vertex_offset, VertexFormatID p_vertex_format, uint32_t p_vertex_count, BufferID p_index_buffer, IndexBufferFormat p_index_format, uint64_t p_index_offset_bytes, uint32_t p_index_count, RDD::BufferID p_transform_buffer, uint64_t p_transform_offset) { + // TODO + return RDD::AccelerationStructureID(); +} + +RDD::AccelerationStructureID RenderingDeviceDriverMetal::tlas_create(const LocalVector &p_blases) { + // TODO + return RDD::AccelerationStructureID(); +} + +void RenderingDeviceDriverMetal::acceleration_structure_free(RDD::AccelerationStructureID p_acceleration_structure) { + // TODO +} + +// ----- PIPELINE ----- + +RDD::RaytracingPipelineID RenderingDeviceDriverMetal::raytracing_pipeline_create(ShaderID p_shader, VectorView p_specialization_constants) { + // TODO + return RaytracingPipelineID(); +} + +void RenderingDeviceDriverMetal::raytracing_pipeline_free(RDD::RaytracingPipelineID p_pipeline) { + // TODO +} + +// ----- COMMANDS ----- + +void RenderingDeviceDriverMetal::command_build_acceleration_structure(CommandBufferID p_cmd_buffer, AccelerationStructureID p_acceleration_structure) { + // TODO +} + +void RenderingDeviceDriverMetal::command_bind_raytracing_pipeline(CommandBufferID p_cmd_buffer, RaytracingPipelineID p_pipeline) { + // TODO +} + +void RenderingDeviceDriverMetal::command_bind_raytracing_uniform_set(CommandBufferID p_cmd_buffer, UniformSetID p_uniform_set, ShaderID p_shader, uint32_t p_set_index) { + // TODO +} + +void RenderingDeviceDriverMetal::command_raytracing_trace_rays(CommandBufferID p_cmd_buffer, RaytracingPipelineID p_pipeline, ShaderID p_shader, uint32_t p_width, uint32_t p_height) { + // TODO +} + #pragma mark - Queries // ----- TIMESTAMP ----- diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index 89321968ada9..de1d9305ef43 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -5265,7 +5265,12 @@ RDD::PipelineID RenderingDeviceDriverVulkan::render_pipeline_create( /**** RAYTRACING ****/ /********************/ +bool RenderingDeviceDriverVulkan::is_raytracing_supported() { + return raytracing_capabilities.buffer_device_address_support && raytracing_capabilities.acceleration_structure_support && raytracing_capabilities.raytracing_pipeline_support; +} + RDD::AccelerationStructureID RenderingDeviceDriverVulkan::blas_create(BufferID p_vertex_buffer, uint64_t p_vertex_offset, VertexFormatID p_vertex_format, uint32_t p_vertex_count, BufferID p_index_buffer, IndexBufferFormat p_index_format, uint64_t p_index_offset_bytes, uint32_t p_index_count, BufferID p_transform_buffer, uint64_t p_transform_offset) { +#if !(defined(MACOS_ENABLED) || defined(IOS_ENABLED)) // Vertex positions is first buffer const VertexFormatInfo *vf_info = (const VertexFormatInfo *)p_vertex_format.id; VkDeviceSize buffer_offset = vf_info->vk_attributes[0].offset; @@ -5322,9 +5327,13 @@ RDD::AccelerationStructureID RenderingDeviceDriverVulkan::blas_create(BufferID p _acceleration_structure_create(VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR, size_info, accel_info); return AccelerationStructureID(accel_info); +#else + return AccelerationStructureID(); +#endif } RDD::AccelerationStructureID RenderingDeviceDriverVulkan::tlas_create(const LocalVector &p_blases) { +#if !(defined(MACOS_ENABLED) || defined(IOS_ENABLED)) AccelerationStructureInfo *accel_info = VersatileResource::allocate(resources_allocator); for (uint32_t i = 0; i < p_blases.size(); ++i) { @@ -5380,9 +5389,13 @@ RDD::AccelerationStructureID RenderingDeviceDriverVulkan::tlas_create(const Loca _acceleration_structure_create(VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, size_info, accel_info); return AccelerationStructureID(accel_info); +#else + return AccelerationStructureID(); +#endif } void RenderingDeviceDriverVulkan::_acceleration_structure_create(VkAccelerationStructureTypeKHR p_type, VkAccelerationStructureBuildSizesInfoKHR p_size_info, AccelerationStructureInfo *r_accel_info) { +#if !(defined(MACOS_ENABLED) || defined(IOS_ENABLED)) RDD::BufferID buffer = buffer_create(p_size_info.accelerationStructureSize, RDD::BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT | RDD::BUFFER_USAGE_STORAGE_BIT | RDD::BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, RDD::MEMORY_ALLOCATION_TYPE_GPU); r_accel_info->buffer = buffer; @@ -5398,9 +5411,11 @@ void RenderingDeviceDriverVulkan::_acceleration_structure_create(VkAccelerationS VkResult err = vkCreateAccelerationStructureKHR(vk_device, &blas_create_info, nullptr, &r_accel_info->vk_acceleration_structure); ERR_FAIL_COND_MSG(err, "vkCreateAccelerationStructureKHR failed with error " + itos(err) + "."); r_accel_info->build_info.dstAccelerationStructure = r_accel_info->vk_acceleration_structure; +#endif } void RenderingDeviceDriverVulkan::acceleration_structure_free(AccelerationStructureID p_acceleration_structure) { +#if !(defined(MACOS_ENABLED) || defined(IOS_ENABLED)) AccelerationStructureInfo *accel_info = (AccelerationStructureInfo *)p_acceleration_structure.id; if (accel_info->instances_buffer) { buffer_free(accel_info->instances_buffer); @@ -5415,14 +5430,17 @@ void RenderingDeviceDriverVulkan::acceleration_structure_free(AccelerationStruct vkDestroyAccelerationStructureKHR(vk_device, accel_info->vk_acceleration_structure, nullptr); } VersatileResource::free(resources_allocator, accel_info); +#endif } // ----- COMMANDS ----- void RenderingDeviceDriverVulkan::command_build_acceleration_structure(CommandBufferID p_cmd_buffer, AccelerationStructureID p_acceleration_structure) { +#if !(defined(MACOS_ENABLED) || defined(IOS_ENABLED)) const AccelerationStructureInfo *accel_info = (const AccelerationStructureInfo *)p_acceleration_structure.id; const VkAccelerationStructureBuildRangeInfoKHR *range_info_ptr = &accel_info->range_info; vkCmdBuildAccelerationStructuresKHR((VkCommandBuffer)p_cmd_buffer.id, 1, &accel_info->build_info, &range_info_ptr); +#endif } void RenderingDeviceDriverVulkan::command_bind_raytracing_pipeline(CommandBufferID p_cmd_buffer, RaytracingPipelineID p_pipeline) { @@ -5437,6 +5455,7 @@ void RenderingDeviceDriverVulkan::command_bind_raytracing_uniform_set(CommandBuf } void RenderingDeviceDriverVulkan::command_raytracing_trace_rays(CommandBufferID p_cmd_buffer, RaytracingPipelineID p_pipeline, ShaderID p_shader, uint32_t p_width, uint32_t p_height) { +#if !(defined(MACOS_ENABLED) || defined(IOS_ENABLED)) ShaderInfo *shader_info = (ShaderInfo *)p_shader.id; const RaytracingPipelineInfo *pipeline_info = (const RaytracingPipelineInfo *)p_pipeline.id; @@ -5471,6 +5490,7 @@ void RenderingDeviceDriverVulkan::command_raytracing_trace_rays(CommandBufferID buffer_unmap(shader_info->sbt_buffer); vkCmdTraceRaysKHR((VkCommandBuffer)p_cmd_buffer.id, &shader_info->regions.raygen, &shader_info->regions.miss, &shader_info->regions.closest_hit, &shader_info->regions.call, p_width, p_height, 1); +#endif } /*****************/ @@ -5535,6 +5555,7 @@ RDD::PipelineID RenderingDeviceDriverVulkan::compute_pipeline_create(ShaderID p_ } RDD::RaytracingPipelineID RenderingDeviceDriverVulkan::raytracing_pipeline_create(ShaderID p_shader, VectorView p_specialization_constants) { +#if !(defined(MACOS_ENABLED) || defined(IOS_ENABLED)) const ShaderInfo *shader_info = (const ShaderInfo *)p_shader.id; VkRayTracingPipelineCreateInfoKHR pipeline_create_info = {}; @@ -5590,6 +5611,9 @@ RDD::RaytracingPipelineID RenderingDeviceDriverVulkan::raytracing_pipeline_creat pipeline_info->vk_pipeline = vk_pipeline; return RaytracingPipelineID(pipeline_info); +#else + return RaytracingPipelineID(); +#endif } void RenderingDeviceDriverVulkan::raytracing_pipeline_free(RaytracingPipelineID p_pipeline) { diff --git a/drivers/vulkan/rendering_device_driver_vulkan.h b/drivers/vulkan/rendering_device_driver_vulkan.h index 309851669eb3..32c08afa646e 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.h +++ b/drivers/vulkan/rendering_device_driver_vulkan.h @@ -682,6 +682,7 @@ class RenderingDeviceDriverVulkan : public RenderingDeviceDriver { VkAccelerationStructureBuildRangeInfoKHR range_info; }; + virtual bool is_raytracing_supported() override final; virtual AccelerationStructureID blas_create(BufferID p_vertex_buffer, uint64_t p_vertex_offset, VertexFormatID p_vertex_format, uint32_t p_vertex_count, BufferID p_index_buffer, IndexBufferFormat p_index_format, uint64_t p_index_offset_bytes, uint32_t p_index_count, BufferID p_transform_buffer, uint64_t p_transform_offset) override final; virtual AccelerationStructureID tlas_create(const LocalVector &p_blases) override final; virtual void acceleration_structure_free(AccelerationStructureID p_acceleration_structure) override final; diff --git a/servers/rendering/renderer_rd/raytracing/render_raytracing.cpp b/servers/rendering/renderer_rd/raytracing/render_raytracing.cpp index 90034a090efe..60af907f4c83 100644 --- a/servers/rendering/renderer_rd/raytracing/render_raytracing.cpp +++ b/servers/rendering/renderer_rd/raytracing/render_raytracing.cpp @@ -1,5 +1,5 @@ /**************************************************************************/ -/* render_raytracing.cpp */ +/* render_raytracing.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -5065,4 +5065,3 @@ RenderRaytracing::~RenderRaytracing() { sdfgi_framebuffer_size_cache.remove(sdfgi_framebuffer_size_cache.begin()); } } - diff --git a/servers/rendering/renderer_rd/raytracing/render_raytracing.h b/servers/rendering/renderer_rd/raytracing/render_raytracing.h index 62995af839cd..8ad098acc885 100644 --- a/servers/rendering/renderer_rd/raytracing/render_raytracing.h +++ b/servers/rendering/renderer_rd/raytracing/render_raytracing.h @@ -1,5 +1,5 @@ /**************************************************************************/ -/* render_raytracing.h */ +/* render_raytracing.h */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifndef RENDER_RAYTRACING_H -#define RENDER_RAYTRACING_H +#ifndef RENDER_RAYTRACING_RD_H +#define RENDER_RAYTRACING_RD_H #include "core/templates/paged_allocator.h" #include "servers/rendering/renderer_rd/cluster_builder_rd.h" @@ -757,5 +757,4 @@ class RenderRaytracing : public RendererSceneRenderRD { }; } // namespace RendererSceneRenderImplementation -#endif // RENDER_RAYTRACING_H - +#endif // RENDER_RAYTRACING_RD_H diff --git a/servers/rendering/renderer_rd/raytracing/scene_shader_raytracing.cpp b/servers/rendering/renderer_rd/raytracing/scene_shader_raytracing.cpp index 15b072d51100..5a34f14ce5b9 100644 --- a/servers/rendering/renderer_rd/raytracing/scene_shader_raytracing.cpp +++ b/servers/rendering/renderer_rd/raytracing/scene_shader_raytracing.cpp @@ -1,5 +1,5 @@ /**************************************************************************/ -/* scene_shader_raytracing.cpp */ +/* scene_shader_raytracing.cpp */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -930,4 +930,3 @@ uint32_t SceneShaderRaytracing::get_pipeline_compilations(RS::PipelineSource p_s MutexLock lock(SceneShaderRaytracing::singleton_mutex); return pipeline_compilations[p_source]; } - diff --git a/servers/rendering/renderer_rd/raytracing/scene_shader_raytracing.h b/servers/rendering/renderer_rd/raytracing/scene_shader_raytracing.h index 6473e030a9e3..52269fd21563 100644 --- a/servers/rendering/renderer_rd/raytracing/scene_shader_raytracing.h +++ b/servers/rendering/renderer_rd/raytracing/scene_shader_raytracing.h @@ -1,5 +1,5 @@ /**************************************************************************/ -/* scene_shader_raytracing.h */ +/* scene_shader_raytracing.h */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#ifndef SCENE_SHADER_RAYTRACING_H -#define SCENE_SHADER_RAYTRACING_H +#ifndef SCENE_SHADER_RAYTRACING_RD_H +#define SCENE_SHADER_RAYTRACING_RD_H #include "servers/rendering/renderer_rd/pipeline_hash_map_rd.h" #include "servers/rendering/renderer_rd/renderer_scene_render_rd.h" @@ -369,5 +369,4 @@ class SceneShaderRaytracing { } // namespace RendererSceneRenderImplementation -#endif // SCENE_SHADER_RAYTRACING_H - +#endif // SCENE_SHADER_RAYTRACING_RD_H diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index da31ec6160d3..c730cafe90bf 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -37,8 +37,8 @@ #include "servers/rendering/renderer_rd/environment/fog.h" #include "servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h" #include "servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h" -#include "servers/rendering/renderer_rd/raytracing/render_raytracing.h" #include "servers/rendering/renderer_rd/framebuffer_cache_rd.h" +#include "servers/rendering/renderer_rd/raytracing/render_raytracing.h" #include "servers/rendering/renderer_rd/renderer_canvas_render_rd.h" #include "servers/rendering/renderer_rd/shaders/blit.glsl.gen.h" #include "servers/rendering/renderer_rd/storage_rd/light_storage.h" diff --git a/servers/rendering/renderer_rd/shaders/raytracing/scene_raytracing_raygen.glsl b/servers/rendering/renderer_rd/shaders/raytracing/scene_raytracing_raygen.glsl index 70680cacdbb3..dfc2fd2bd15b 100644 --- a/servers/rendering/renderer_rd/shaders/raytracing/scene_raytracing_raygen.glsl +++ b/servers/rendering/renderer_rd/shaders/raytracing/scene_raytracing_raygen.glsl @@ -21,8 +21,8 @@ layout(set = 0, binding = 1) uniform accelerationStructureEXT tlas; layout(set = 0, binding = 2, std140) uniform SceneDataBlock { SceneData data; -} scene_data_block; - +} +scene_data_block; void main() { const vec2 pixel_center = vec2(gl_LaunchIDEXT.xy) + vec2(0.5); diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index c8b107711aca..7422e9a41955 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -4361,6 +4361,10 @@ void RenderingDevice::draw_list_bind_index_array(DrawListID p_list, RID p_index_ } } +bool RenderingDevice::is_raytracing_supported() { + return driver->is_raytracing_supported(); +} + RID RenderingDevice::blas_create(RID p_vertex_array, RID p_index_array, RID p_transform_buffer, uint64_t p_transform_offset) { ERR_RENDER_THREAD_GUARD_V(RID()); @@ -7243,6 +7247,7 @@ void RenderingDevice::_bind_methods() { ClassDB::bind_method(D_METHOD("raytracing_pipeline_create", "shader"), &RenderingDevice::_raytracing_pipeline_create, DEFVAL(TypedArray())); ClassDB::bind_method(D_METHOD("raytracing_pipeline_is_valid", "raytracing_pipeline"), &RenderingDevice::raytracing_pipeline_is_valid); + ClassDB::bind_method(D_METHOD("is_raytracing_supported"), &RenderingDevice::is_raytracing_supported); ClassDB::bind_method(D_METHOD("blas_create", "vertex_array", "index_array", "transform_buffer", "transform_offset"), &RenderingDevice::blas_create, DEFVAL(0)); ClassDB::bind_method(D_METHOD("tlas_create", "blases"), &RenderingDevice::_tlas_create); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index bee8c481e0b0..2139523c97b2 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -1217,6 +1217,7 @@ class RenderingDevice : public RenderingDeviceCommons { RID_Owner acceleration_structure_owner; public: + bool is_raytracing_supported(); RID blas_create(RID p_vertex_array, RID p_index_array, RID p_transform_buffer, uint64_t p_transform_offset); RID tlas_create(const Vector &blases); diff --git a/servers/rendering/rendering_device_driver.h b/servers/rendering/rendering_device_driver.h index 24e6a2242cab..7444df1fc962 100644 --- a/servers/rendering/rendering_device_driver.h +++ b/servers/rendering/rendering_device_driver.h @@ -707,6 +707,10 @@ class RenderingDeviceDriver : public RenderingDeviceCommons { /**** RAYTRACING ****/ /********************/ + virtual bool is_raytracing_supported() { + return false; + } + // ----- ACCELERATION STRUCTURE ----- enum AccelerationStructureType {