|
14 | 14 | <link title="Using compute shaders">$DOCS_URL/tutorials/shaders/compute_shaders.html</link> |
15 | 15 | </tutorials> |
16 | 16 | <methods> |
| 17 | + <method name="acceleration_structure_build"> |
| 18 | + <return type="int" enum="Error" /> |
| 19 | + <param index="0" name="acceleration_structure" type="RID" /> |
| 20 | + <description> |
| 21 | + Builds the [param acceleration_structure]. |
| 22 | + </description> |
| 23 | + </method> |
17 | 24 | <method name="barrier" deprecated="Barriers are automatically inserted by RenderingDevice."> |
18 | 25 | <return type="void" /> |
19 | 26 | <param index="0" name="from" type="int" enum="RenderingDevice.BarrierMask" is_bitfield="true" default="32767" /> |
|
22 | 29 | This method does nothing. |
23 | 30 | </description> |
24 | 31 | </method> |
| 32 | + <method name="blas_create"> |
| 33 | + <return type="RID" /> |
| 34 | + <param index="0" name="vertex_array" type="RID" /> |
| 35 | + <param index="1" name="index_array" type="RID" /> |
| 36 | + <param index="2" name="geometry_bits" type="int" enum="RenderingDevice.AccelerationStructureGeometryBits" is_bitfield="true" default="0" /> |
| 37 | + <param index="3" name="position_attribute_location" type="int" default="0" /> |
| 38 | + <description> |
| 39 | + Creates a new Bottom Level Acceleration Structure. It can be accessed with the RID that is returned. |
| 40 | + Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method. |
| 41 | + [param position_attribute_location] selects which vertex attribute location supplies the position data (default is 0). |
| 42 | + </description> |
| 43 | + </method> |
25 | 44 | <method name="buffer_clear"> |
26 | 45 | <return type="int" enum="Error" /> |
27 | 46 | <param index="0" name="buffer" type="RID" /> |
|
732 | 751 | Limits for various graphics hardware can be found in the [url=https://vulkan.gpuinfo.org/]Vulkan Hardware Database[/url]. |
733 | 752 | </description> |
734 | 753 | </method> |
| 754 | + <method name="raytracing_list_begin"> |
| 755 | + <return type="int" /> |
| 756 | + <description> |
| 757 | + Starts a list of raytracing commands. The returned value should be passed to other [code]raytracing_list_*[/code] functions. |
| 758 | + Multiple raytracing lists cannot be created at the same time; you must finish the previous raytracing list first using [method raytracing_list_end]. |
| 759 | + A simple raytracing operation might look like this (code is not a complete example): |
| 760 | + [codeblocks] |
| 761 | + [gdscript] |
| 762 | + var rd = RenderingDevice.new() |
| 763 | + assert(rd.has_feature(RenderingDevice.SUPPORTS_RAYTRACING_PIPELINE)) |
| 764 | + |
| 765 | + # Create a BLAS for a mesh. |
| 766 | + blas = rd.blas_create(vertex_array, index_array, RenderingDevice.ACCELERATION_STRUCTURE_GEOMETRY_OPAQUE) |
| 767 | + # Create TLAS with BLASs. |
| 768 | + instances_buffer = rd.tlas_instances_buffer_create(1) |
| 769 | + rd.tlas_instances_buffer_fill(instances_buffer, [blas], [Transform3D()]) |
| 770 | + tlas = rd.tlas_create(instances_buffer) |
| 771 | + |
| 772 | + # Build acceleration structures. |
| 773 | + rd.acceleration_structure_build(blas) |
| 774 | + rd.acceleration_structure_build(tlas) |
| 775 | + |
| 776 | + var raylist = rd.raytracing_list_begin() |
| 777 | + |
| 778 | + # Bind pipeline and uniforms. |
| 779 | + rd.raytracing_list_bind_raytracing_pipeline(raylist, raytracing_pipeline) |
| 780 | + rd.raytracing_list_bind_uniform_set(raylist, uniform_set, 0) |
| 781 | + |
| 782 | + # Trace rays. |
| 783 | + var width = get_viewport().size.x |
| 784 | + var height = get_viewport().size.y |
| 785 | + rd.raytracing_list_trace_rays(raylist, width, height) |
| 786 | + |
| 787 | + rd.raytracing_list_end() |
| 788 | + [/gdscript] |
| 789 | + [/codeblocks] |
| 790 | + </description> |
| 791 | + </method> |
| 792 | + <method name="raytracing_list_bind_raytracing_pipeline"> |
| 793 | + <return type="void" /> |
| 794 | + <param index="0" name="raytracing_list" type="int" /> |
| 795 | + <param index="1" name="raytracing_pipeline" type="RID" /> |
| 796 | + <description> |
| 797 | + Binds [param raytracing_pipeline] to the specified [param raytracing_list]. |
| 798 | + </description> |
| 799 | + </method> |
| 800 | + <method name="raytracing_list_bind_uniform_set"> |
| 801 | + <return type="void" /> |
| 802 | + <param index="0" name="raytracing_list" type="int" /> |
| 803 | + <param index="1" name="uniform_set" type="RID" /> |
| 804 | + <param index="2" name="set_index" type="int" /> |
| 805 | + <description> |
| 806 | + Binds the [param uniform_set] to this [param raytracing_list]. |
| 807 | + </description> |
| 808 | + </method> |
| 809 | + <method name="raytracing_list_end"> |
| 810 | + <return type="void" /> |
| 811 | + <description> |
| 812 | + Finishes a list of raytracing commands created with the [code]raytracing_*[/code] methods. |
| 813 | + </description> |
| 814 | + </method> |
| 815 | + <method name="raytracing_list_set_push_constant"> |
| 816 | + <return type="void" /> |
| 817 | + <param index="0" name="raytracing_list" type="int" /> |
| 818 | + <param index="1" name="buffer" type="PackedByteArray" /> |
| 819 | + <param index="2" name="size_bytes" type="int" /> |
| 820 | + <description> |
| 821 | + Sets the push constant data to [param buffer] for the specified [param raytracing_list]. The shader determines how this binary data is used. The buffer's size in bytes must also be specified in [param size_bytes] (this can be obtained by calling the [method PackedByteArray.size] method on the passed [param buffer]). |
| 822 | + </description> |
| 823 | + </method> |
| 824 | + <method name="raytracing_list_trace_rays"> |
| 825 | + <return type="void" /> |
| 826 | + <param index="0" name="raytracing_list" type="int" /> |
| 827 | + <param index="1" name="width" type="int" /> |
| 828 | + <param index="2" name="height" type="int" /> |
| 829 | + <description> |
| 830 | + Initializes a ray tracing dispatch for the specified [param raytracing_list] assembling a group of [param width] x [param height] rays. |
| 831 | + </description> |
| 832 | + </method> |
| 833 | + <method name="raytracing_pipeline_create"> |
| 834 | + <return type="RID" /> |
| 835 | + <param index="0" name="shader" type="RID" /> |
| 836 | + <param index="1" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]" /> |
| 837 | + <description> |
| 838 | + Creates a new raytracing pipeline. It can be accessed with the RID that is returned. |
| 839 | + Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method. |
| 840 | + [b]Note:[/b]: Recursive raytracing is not permitted. |
| 841 | + </description> |
| 842 | + </method> |
| 843 | + <method name="raytracing_pipeline_is_valid"> |
| 844 | + <return type="bool" /> |
| 845 | + <param index="0" name="raytracing_pipeline" type="RID" /> |
| 846 | + <description> |
| 847 | + Returns [code]true[/code] if the raytracing pipeline specified by the [param raytracing_pipeline] RID is valid, [code]false[/code] otherwise. |
| 848 | + </description> |
| 849 | + </method> |
735 | 850 | <method name="render_pipeline_create"> |
736 | 851 | <return type="RID" /> |
737 | 852 | <param index="0" name="shader" type="RID" /> |
|
1089 | 1204 | [b]Note:[/b] The existing [param texture] requires the [constant TEXTURE_USAGE_CAN_UPDATE_BIT] to be updatable. |
1090 | 1205 | </description> |
1091 | 1206 | </method> |
| 1207 | + <method name="tlas_create"> |
| 1208 | + <return type="RID" /> |
| 1209 | + <param index="0" name="instances_buffer" type="RID" /> |
| 1210 | + <description> |
| 1211 | + Creates a new Top Level Acceleration Structure. It can be accessed with the RID that is returned. |
| 1212 | + The instances buffer passed as input is expected to be filled before building the TLAS. |
| 1213 | + Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method. |
| 1214 | + </description> |
| 1215 | + </method> |
| 1216 | + <method name="tlas_instances_buffer_create"> |
| 1217 | + <return type="RID" /> |
| 1218 | + <param index="0" name="instance_count" type="int" /> |
| 1219 | + <param index="1" name="creation_bits" type="int" enum="RenderingDevice.BufferCreationBits" is_bitfield="true" default="0" /> |
| 1220 | + <description> |
| 1221 | + Creates a new instances buffer which can be used to create a TLAS. It can be accessed with the RID that is returned. |
| 1222 | + Once finished with your RID, you will want to free the RID using the RenderingDevice's [method free_rid] method. |
| 1223 | + </description> |
| 1224 | + </method> |
| 1225 | + <method name="tlas_instances_buffer_fill"> |
| 1226 | + <return type="void" /> |
| 1227 | + <param index="0" name="instances_buffer" type="RID" /> |
| 1228 | + <param index="1" name="blases" type="RID[]" /> |
| 1229 | + <param index="2" name="transforms" type="Transform3D[]" /> |
| 1230 | + <description> |
| 1231 | + Fills the content of an instances buffer. The number of BLASes and transforms passed as input should be the same and should equal the instance count used at instance buffer creation time. |
| 1232 | + </description> |
| 1233 | + </method> |
1092 | 1234 | <method name="uniform_buffer_create"> |
1093 | 1235 | <return type="RID" /> |
1094 | 1236 | <param index="0" name="size_bytes" type="int" /> |
|
2145 | 2287 | <constant name="BUFFER_CREATION_AS_STORAGE_BIT" value="2" enum="BufferCreationBits" is_bitfield="true"> |
2146 | 2288 | Set this flag so that it is created as storage. This is useful if Compute Shaders need access (for reading or writing) to the buffer, e.g. skeletal animations are processed in Compute Shaders which need access to vertex buffers, to be later consumed by vertex shaders as part of the regular rasterization pipeline. |
2147 | 2289 | </constant> |
| 2290 | + <constant name="BUFFER_CREATION_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT" value="8" enum="BufferCreationBits" is_bitfield="true"> |
| 2291 | + Allows usage of this buffer as input data for an acceleration structure build operation. You must first check the GPU supports it: |
| 2292 | + [codeblocks] |
| 2293 | + [gdscript] |
| 2294 | + rd = RenderingServer.get_rendering_device() |
| 2295 | + |
| 2296 | + if rd.has_feature(RenderingDevice.SUPPORTS_RAYTRACING_PIPELINE): |
| 2297 | + storage_buffer = rd.storage_buffer_create(bytes.size(), bytes, RenderingDevice.BUFFER_CREATION_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT) |
| 2298 | + [/gdscript] |
| 2299 | + [/codeblocks] |
| 2300 | + </constant> |
| 2301 | + <constant name="ACCELERATION_STRUCTURE_GEOMETRY_OPAQUE" value="1" enum="AccelerationStructureGeometryBits" is_bitfield="true"> |
| 2302 | + An opaque geometry does not invoke the any-hit shaders. |
| 2303 | + </constant> |
| 2304 | + <constant name="ACCELERATION_STRUCTURE_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION" value="2" enum="AccelerationStructureGeometryBits" is_bitfield="true"> |
| 2305 | + This geometry only calls the any-hit shader a single time for each primitive. |
| 2306 | + </constant> |
2148 | 2307 | <constant name="UNIFORM_TYPE_SAMPLER" value="0" enum="UniformType"> |
2149 | 2308 | Sampler uniform. |
2150 | 2309 | </constant> |
|
2185 | 2344 | [b]Note:[/b] This flag is not available to GD users due to being too dangerous (i.e. wrong usage can result in visual glitches). |
2186 | 2345 | It's exposed in case GD users receive a buffer created with such flag from Godot. |
2187 | 2346 | </constant> |
2188 | | - <constant name="UNIFORM_TYPE_MAX" value="12" enum="UniformType"> |
| 2347 | + <constant name="UNIFORM_TYPE_ACCELERATION_STRUCTURE" value="12" enum="UniformType"> |
| 2348 | + Acceleration structure uniform. |
| 2349 | + </constant> |
| 2350 | + <constant name="UNIFORM_TYPE_MAX" value="13" enum="UniformType"> |
2189 | 2351 | Represents the size of the [enum UniformType] enum. |
2190 | 2352 | </constant> |
2191 | 2353 | <constant name="RENDER_PRIMITIVE_POINTS" value="0" enum="RenderPrimitive"> |
|
2493 | 2655 | <constant name="SHADER_STAGE_COMPUTE" value="4" enum="ShaderStage"> |
2494 | 2656 | Compute shader stage. This can be used to run arbitrary computing tasks in a shader, performing them on the GPU instead of the CPU. |
2495 | 2657 | </constant> |
2496 | | - <constant name="SHADER_STAGE_MAX" value="5" enum="ShaderStage"> |
| 2658 | + <constant name="SHADER_STAGE_RAYGEN" value="5" enum="ShaderStage"> |
| 2659 | + Ray generation shader stage. This can be used to generate primary rays. |
| 2660 | + </constant> |
| 2661 | + <constant name="SHADER_STAGE_ANY_HIT" value="6" enum="ShaderStage"> |
| 2662 | + Any hit shader stage. Invoked when ray intersections are not opaque. This can be used when to specify what happens when a ray hits any of the geometry in the scene. |
| 2663 | + </constant> |
| 2664 | + <constant name="SHADER_STAGE_CLOSEST_HIT" value="7" enum="ShaderStage"> |
| 2665 | + Closest hit shader stage. This can be used to specify what happens when a ray hits the closest geometry in the scene. |
| 2666 | + </constant> |
| 2667 | + <constant name="SHADER_STAGE_MISS" value="8" enum="ShaderStage"> |
| 2668 | + Miss shader stage. This can be used to specify what happens if a ray does not hit anything in the scene. |
| 2669 | + </constant> |
| 2670 | + <constant name="SHADER_STAGE_INTERSECTION" value="9" enum="ShaderStage"> |
| 2671 | + Intersection shader stage. The intersection shader for triangles is built-in. This can be used to compute ray intersections with primitives that are not triangles. |
| 2672 | + </constant> |
| 2673 | + <constant name="SHADER_STAGE_MAX" value="10" enum="ShaderStage"> |
2497 | 2674 | Represents the size of the [enum ShaderStage] enum. |
2498 | 2675 | </constant> |
2499 | 2676 | <constant name="SHADER_STAGE_VERTEX_BIT" value="1" enum="ShaderStage"> |
|
2511 | 2688 | <constant name="SHADER_STAGE_COMPUTE_BIT" value="16" enum="ShaderStage"> |
2512 | 2689 | Compute shader stage bit (see also [constant SHADER_STAGE_COMPUTE]). |
2513 | 2690 | </constant> |
| 2691 | + <constant name="SHADER_STAGE_RAYGEN_BIT" value="32" enum="ShaderStage"> |
| 2692 | + Ray generation shader stage bit (see also [constant SHADER_STAGE_RAYGEN]). |
| 2693 | + </constant> |
| 2694 | + <constant name="SHADER_STAGE_ANY_HIT_BIT" value="64" enum="ShaderStage"> |
| 2695 | + Any hit shader stage bit (see also [constant SHADER_STAGE_ANY_HIT]). |
| 2696 | + </constant> |
| 2697 | + <constant name="SHADER_STAGE_CLOSEST_HIT_BIT" value="128" enum="ShaderStage"> |
| 2698 | + Closest hit shader stage bit (see also [constant SHADER_STAGE_CLOSEST_HIT]). |
| 2699 | + </constant> |
| 2700 | + <constant name="SHADER_STAGE_MISS_BIT" value="256" enum="ShaderStage"> |
| 2701 | + Miss shader stage bit (see also [constant SHADER_STAGE_MISS]). |
| 2702 | + </constant> |
| 2703 | + <constant name="SHADER_STAGE_INTERSECTION_BIT" value="512" enum="ShaderStage"> |
| 2704 | + Intersection shader stage bit (see also [constant SHADER_STAGE_INTERSECTION]). |
| 2705 | + </constant> |
2514 | 2706 | <constant name="SHADER_LANGUAGE_GLSL" value="0" enum="ShaderLanguage"> |
2515 | 2707 | Khronos' GLSL shading language (used natively by OpenGL and Vulkan). This is the language used for core Godot shaders. |
2516 | 2708 | </constant> |
|
2538 | 2730 | <constant name="SUPPORTS_IMAGE_ATOMIC_32_BIT" value="7" enum="Features"> |
2539 | 2731 | Support for 32-bit image atomic operations. |
2540 | 2732 | </constant> |
| 2733 | + <constant name="SUPPORTS_RAY_QUERY" value="11" enum="Features"> |
| 2734 | + Support for ray query extension. |
| 2735 | + </constant> |
| 2736 | + <constant name="SUPPORTS_RAYTRACING_PIPELINE" value="12" enum="Features"> |
| 2737 | + Support for raytracing pipeline extension. |
| 2738 | + </constant> |
2541 | 2739 | <constant name="LIMIT_MAX_BOUND_UNIFORM_SETS" value="0" enum="Limit"> |
2542 | 2740 | Maximum number of uniform sets that can be bound at a given time. |
2543 | 2741 | </constant> |
|
0 commit comments