mirror of
https://github.com/godotengine/godot
synced 2024-09-18 20:11:29 +00:00
Fix unsupported sampler filter used for voxel GI
This commit is contained in:
parent
2beed0d5dc
commit
09aa1bbdb3
|
@ -452,6 +452,14 @@
|
||||||
<description>
|
<description>
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="sampler_is_format_supported_for_filter" qualifiers="const">
|
||||||
|
<return type="bool" />
|
||||||
|
<param index="0" name="format" type="int" enum="RenderingDevice.DataFormat" />
|
||||||
|
<param index="1" name="sampler_filter" type="int" enum="RenderingDevice.SamplerFilter" />
|
||||||
|
<description>
|
||||||
|
Returns [code]true[/code] if implementation supports using a texture of [param format] with the given [param sampler_filter].
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="screen_get_framebuffer_format" qualifiers="const">
|
<method name="screen_get_framebuffer_format" qualifiers="const">
|
||||||
<return type="int" />
|
<return type="int" />
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -4305,6 +4305,18 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RenderingDeviceVulkan::sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_sampler_filter) const {
|
||||||
|
ERR_FAIL_INDEX_V(p_format, DATA_FORMAT_MAX, false);
|
||||||
|
|
||||||
|
_THREAD_SAFE_METHOD_
|
||||||
|
|
||||||
|
// Validate that this image is supported for the intended filtering.
|
||||||
|
VkFormatProperties properties;
|
||||||
|
vkGetPhysicalDeviceFormatProperties(context->get_physical_device(), vulkan_formats[p_format], &properties);
|
||||||
|
|
||||||
|
return p_sampler_filter == RD::SAMPLER_FILTER_NEAREST || (p_sampler_filter == RD::SAMPLER_FILTER_LINEAR && (properties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT));
|
||||||
|
}
|
||||||
|
|
||||||
/**********************/
|
/**********************/
|
||||||
/**** VERTEX ARRAY ****/
|
/**** VERTEX ARRAY ****/
|
||||||
/**********************/
|
/**********************/
|
||||||
|
|
|
@ -1084,6 +1084,7 @@ public:
|
||||||
/*****************/
|
/*****************/
|
||||||
|
|
||||||
virtual RID sampler_create(const SamplerState &p_state);
|
virtual RID sampler_create(const SamplerState &p_state);
|
||||||
|
virtual bool sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_sampler_filter) const;
|
||||||
|
|
||||||
/**********************/
|
/**********************/
|
||||||
/**** VERTEX ARRAY ****/
|
/**** VERTEX ARRAY ****/
|
||||||
|
|
|
@ -3493,6 +3493,9 @@ void GI::init(SkyRD *p_sky) {
|
||||||
if (RendererSceneRenderRD::get_singleton()->is_vrs_supported()) {
|
if (RendererSceneRenderRD::get_singleton()->is_vrs_supported()) {
|
||||||
defines += "\n#define USE_VRS\n";
|
defines += "\n#define USE_VRS\n";
|
||||||
}
|
}
|
||||||
|
if (!RD::get_singleton()->sampler_is_format_supported_for_filter(RD::DATA_FORMAT_R8G8_UINT, RD::SAMPLER_FILTER_LINEAR)) {
|
||||||
|
defines += "\n#define SAMPLE_VOXEL_GI_NEAREST\n";
|
||||||
|
}
|
||||||
|
|
||||||
Vector<String> gi_modes;
|
Vector<String> gi_modes;
|
||||||
|
|
||||||
|
@ -3931,7 +3934,6 @@ void GI::process_gi(Ref<RenderSceneBuffersRD> p_render_buffers, const RID *p_nor
|
||||||
u.append_id(material_storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
|
u.append_id(material_storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED));
|
||||||
uniforms.push_back(u);
|
uniforms.push_back(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
RD::Uniform u;
|
RD::Uniform u;
|
||||||
u.uniform_type = RD::UNIFORM_TYPE_IMAGE;
|
u.uniform_type = RD::UNIFORM_TYPE_IMAGE;
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
#VERSION_DEFINES
|
#VERSION_DEFINES
|
||||||
|
|
||||||
|
#ifdef SAMPLE_VOXEL_GI_NEAREST
|
||||||
|
#extension GL_EXT_samplerless_texture_functions : enable
|
||||||
|
#endif
|
||||||
|
|
||||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||||
|
|
||||||
#define M_PI 3.141592
|
#define M_PI 3.141592
|
||||||
|
@ -625,7 +629,11 @@ void process_gi(ivec2 pos, vec3 vertex, inout vec4 ambient_light, inout vec4 ref
|
||||||
|
|
||||||
#ifdef USE_VOXEL_GI_INSTANCES
|
#ifdef USE_VOXEL_GI_INSTANCES
|
||||||
{
|
{
|
||||||
|
#ifdef SAMPLE_VOXEL_GI_NEAREST
|
||||||
|
uvec2 voxel_gi_tex = texelFetch(voxel_gi_buffer, pos, 0).rg;
|
||||||
|
#else
|
||||||
uvec2 voxel_gi_tex = texelFetch(usampler2D(voxel_gi_buffer, linear_sampler), pos, 0).rg;
|
uvec2 voxel_gi_tex = texelFetch(usampler2D(voxel_gi_buffer, linear_sampler), pos, 0).rg;
|
||||||
|
#endif
|
||||||
roughness *= roughness;
|
roughness *= roughness;
|
||||||
//find arbitrary tangent and bitangent, then build a matrix
|
//find arbitrary tangent and bitangent, then build a matrix
|
||||||
vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);
|
vec3 v0 = abs(normal.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(0.0, 1.0, 0.0);
|
||||||
|
|
|
@ -723,6 +723,7 @@ void RenderingDevice::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("framebuffer_is_valid", "framebuffer"), &RenderingDevice::framebuffer_is_valid);
|
ClassDB::bind_method(D_METHOD("framebuffer_is_valid", "framebuffer"), &RenderingDevice::framebuffer_is_valid);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("sampler_create", "state"), &RenderingDevice::_sampler_create);
|
ClassDB::bind_method(D_METHOD("sampler_create", "state"), &RenderingDevice::_sampler_create);
|
||||||
|
ClassDB::bind_method(D_METHOD("sampler_is_format_supported_for_filter", "format", "sampler_filter"), &RenderingDevice::sampler_is_format_supported_for_filter);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("vertex_buffer_create", "size_bytes", "data", "use_as_storage"), &RenderingDevice::vertex_buffer_create, DEFVAL(Vector<uint8_t>()), DEFVAL(false));
|
ClassDB::bind_method(D_METHOD("vertex_buffer_create", "size_bytes", "data", "use_as_storage"), &RenderingDevice::vertex_buffer_create, DEFVAL(Vector<uint8_t>()), DEFVAL(false));
|
||||||
ClassDB::bind_method(D_METHOD("vertex_format_create", "vertex_descriptions"), &RenderingDevice::_vertex_format_create);
|
ClassDB::bind_method(D_METHOD("vertex_format_create", "vertex_descriptions"), &RenderingDevice::_vertex_format_create);
|
||||||
|
|
|
@ -653,6 +653,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual RID sampler_create(const SamplerState &p_state) = 0;
|
virtual RID sampler_create(const SamplerState &p_state) = 0;
|
||||||
|
virtual bool sampler_is_format_supported_for_filter(DataFormat p_format, SamplerFilter p_sampler_filter) const = 0;
|
||||||
|
|
||||||
/**********************/
|
/**********************/
|
||||||
/**** VERTEX ARRAY ****/
|
/**** VERTEX ARRAY ****/
|
||||||
|
|
Loading…
Reference in a new issue