Skip to content

Commit

Permalink
Adding Variable Rate Shading support to Godot
Browse files Browse the repository at this point in the history
Improve GI renderer and add VRS support
Implement render device has_feature and move subgroup settings to limit_get
  • Loading branch information
BastiaanOlij committed Jul 17, 2022
1 parent e3a8ab6 commit d139131
Show file tree
Hide file tree
Showing 44 changed files with 1,571 additions and 463 deletions.
6 changes: 6 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,12 @@
If [code]true[/code], the texture importer will import VRAM-compressed textures using the S3 Texture Compression algorithm. This algorithm is only supported on desktop platforms and consoles.
[b]Note:[/b] Changing this setting does [i]not[/i] impact textures that were already imported before. To make this setting apply to textures that were already imported, exit the editor, remove the [code].godot/imported/[/code] folder located inside the project folder then restart the editor (see [member application/config/use_hidden_project_data_directory]).
</member>
<member name="rendering/vrs/mode" type="int" setter="" getter="" default="0">
Set the default Variable Rate Shading (VRS) mode for the main viewport. See [member Viewport.vrs_mode] to change this at runtime, and [enum Viewport.VRSMode] for possible values.
</member>
<member name="rendering/vrs/texture" type="String" setter="" getter="" default="&quot;&quot;">
If [member rendering/vrs/mode] is set to texture, this is the path to default texture loaded as the VRS image.
</member>
<member name="rendering/vulkan/descriptor_pools/max_descriptors_per_pool" type="int" setter="" getter="" default="64">
</member>
<member name="rendering/vulkan/rendering/back_end" type="int" setter="" getter="" default="0">
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/RenderingDevice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
<description>
</description>
</method>
<method name="limit_get">
<method name="limit_get" qualifiers="const">
<return type="int" />
<argument index="0" name="limit" type="int" enum="RenderingDevice.Limit" />
<description>
Expand Down
28 changes: 28 additions & 0 deletions doc/classes/RenderingServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3357,6 +3357,22 @@
If [code]true[/code], the viewport uses augmented or virtual reality technologies. See [XRInterface].
</description>
</method>
<method name="viewport_set_vrs_mode">
<return type="void" />
<argument index="0" name="viewport" type="RID" />
<argument index="1" name="mode" type="int" enum="RenderingServer.ViewportVRSMode" />
<description>
Sets the Variable Rate Shading (VRS) mode for the viewport. Note, if hardware does not support VRS this property is ignored.
</description>
</method>
<method name="viewport_set_vrs_texture">
<return type="void" />
<argument index="0" name="viewport" type="RID" />
<argument index="1" name="texture" type="RID" />
<description>
Texture to use when the VRS mode is set to [constant RenderingServer.VIEWPORT_VRS_TEXTURE].
</description>
</method>
<method name="visibility_notifier_create">
<return type="RID" />
<description>
Expand Down Expand Up @@ -4116,6 +4132,18 @@
</constant>
<constant name="VIEWPORT_DEBUG_DRAW_MOTION_VECTORS" value="25" enum="ViewportDebugDraw">
</constant>
<constant name="VIEWPORT_VRS_DISABLED" value="0" enum="ViewportVRSMode">
VRS is disabled.
</constant>
<constant name="VIEWPORT_VRS_TEXTURE" value="1" enum="ViewportVRSMode">
VRS uses a texture. Note, for stereoscopic use a texture atlas with a texture for each view.
</constant>
<constant name="VIEWPORT_VRS_XR" value="2" enum="ViewportVRSMode">
VRS texture is supplied by the primary [XRInterface].
</constant>
<constant name="VIEWPORT_VRS_MAX" value="3" enum="ViewportVRSMode">
Represents the size of the [enum ViewportVRSMode] enum.
</constant>
<constant name="SKY_MODE_AUTOMATIC" value="0" enum="SkyMode">
</constant>
<constant name="SKY_MODE_QUALITY" value="1" enum="SkyMode">
Expand Down
18 changes: 18 additions & 0 deletions doc/classes/Viewport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@
<member name="use_xr" type="bool" setter="set_use_xr" getter="is_using_xr" default="false">
If [code]true[/code], the viewport will use the primary XR interface to render XR output. When applicable this can result in a stereoscopic image and the resulting render being output to a headset.
</member>
<member name="vrs_mode" type="int" setter="set_vrs_mode" getter="get_vrs_mode" enum="Viewport.VRSMode" default="0">
The Variable Rate Shading (VRS) mode that is used for this viewport. Note, if hardware does not support VRS this property is ignored.
</member>
<member name="vrs_texture" type="Texture2D" setter="set_vrs_texture" getter="get_vrs_texture">
Texture to use when [member vrs_mode] is set to [constant Viewport.VRS_TEXTURE].
</member>
<member name="world_2d" type="World2D" setter="set_world_2d" getter="get_world_2d">
The custom [World2D] which can be used as 2D environment source.
</member>
Expand Down Expand Up @@ -492,5 +498,17 @@
</constant>
<constant name="SDF_SCALE_MAX" value="3" enum="SDFScale">
</constant>
<constant name="VRS_DISABLED" value="0" enum="VRSMode">
VRS is disabled.
</constant>
<constant name="VRS_TEXTURE" value="1" enum="VRSMode">
VRS uses a texture. Note, for stereoscopic use a texture atlas with a texture for each view.
</constant>
<constant name="VRS_XR" value="2" enum="VRSMode">
VRS texture is supplied by the primary [XRInterface].
</constant>
<constant name="VRS_MAX" value="3" enum="VRSMode">
Represents the size of the [enum VRSMode] enum.
</constant>
</constants>
</class>
5 changes: 5 additions & 0 deletions doc/classes/XRInterfaceExtension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
Returns the number of views this interface requires, 1 for mono, 2 for stereoscopic.
</description>
</method>
<method name="_get_vrs_texture" qualifiers="virtual">
<return type="RID" />
<description>
</description>
</method>
<method name="_initialize" qualifiers="virtual">
<return type="bool" />
<description>
Expand Down
10 changes: 10 additions & 0 deletions drivers/gles3/storage/texture_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,16 @@ class TextureStorage : public RendererTextureStorage {
void render_target_copy_to_back_buffer(RID p_render_target, const Rect2i &p_region, bool p_gen_mipmaps);
void render_target_clear_back_buffer(RID p_render_target, const Rect2i &p_region, const Color &p_color);
void render_target_gen_back_buffer_mipmaps(RID p_render_target, const Rect2i &p_region);
virtual void render_target_set_vrs_mode(RID p_render_target, RS::ViewportVRSMode p_mode) override{};
virtual void render_target_set_vrs_texture(RID p_render_target, RID p_texture) override{};

void bind_framebuffer(GLuint framebuffer) {
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
}

void bind_framebuffer_system() {
glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo);
}

String get_framebuffer_error(GLenum p_status);
};
Expand Down
Loading

0 comments on commit d139131

Please sign in to comment.