mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-10-20 18:59:26 +02:00
[spirv] mark sampled image descriptor indices non-uniform (#3900)
fixes incorrect texture selection on vk when shaders use per-pixel descriptor indices, in line with #3898 so dynamic descs are no longer treated as uniform also fixes TD;LTD spotty grass issue on SD not addressed by above pr you can test out all the fixes here: https://git.eden-emu.dev/may/eden/src/branch/may/integrate-texture-descriptor-fixes Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3900 Reviewed-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
parent
a76c76d122
commit
27e5cb0f12
4 changed files with 57 additions and 5 deletions
|
|
@ -14,6 +14,38 @@
|
||||||
|
|
||||||
namespace Shader::Backend::SPIRV {
|
namespace Shader::Backend::SPIRV {
|
||||||
namespace {
|
namespace {
|
||||||
|
class DescriptorIndex {
|
||||||
|
public:
|
||||||
|
explicit DescriptorIndex(EmitContext& ctx, const IR::Value& index)
|
||||||
|
: id{index.IsImmediate() ? ctx.Const(index.U32()) : ctx.Def(index)},
|
||||||
|
is_non_uniform{ctx.profile.support_sampled_image_array_nonuniform_indexing &&
|
||||||
|
!index.IsImmediate()} {
|
||||||
|
if (!is_non_uniform) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ctx.profile.supported_spirv < 0x00010400) {
|
||||||
|
ctx.AddExtension("SPV_EXT_descriptor_indexing");
|
||||||
|
}
|
||||||
|
ctx.AddCapability(spv::Capability::ShaderNonUniform);
|
||||||
|
ctx.AddCapability(spv::Capability::SampledImageArrayNonUniformIndexing);
|
||||||
|
Decorate(ctx, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Id Value() const {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorate(EmitContext& ctx, Id object) const {
|
||||||
|
if (is_non_uniform) {
|
||||||
|
ctx.Decorate(object, spv::Decoration::NonUniform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Id id;
|
||||||
|
bool is_non_uniform;
|
||||||
|
};
|
||||||
|
|
||||||
class ImageOperands {
|
class ImageOperands {
|
||||||
public:
|
public:
|
||||||
[[maybe_unused]] static constexpr bool ImageSampleOffsetAllowed = false;
|
[[maybe_unused]] static constexpr bool ImageSampleOffsetAllowed = false;
|
||||||
|
|
@ -189,8 +221,12 @@ private:
|
||||||
Id Texture(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR::Value& index) {
|
Id Texture(EmitContext& ctx, IR::TextureInstInfo info, [[maybe_unused]] const IR::Value& index) {
|
||||||
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
||||||
if (def.count > 1) {
|
if (def.count > 1) {
|
||||||
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, ctx.Def(index))};
|
const DescriptorIndex idx{ctx, index};
|
||||||
return ctx.OpLoad(def.sampled_type, pointer);
|
const Id pointer{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())};
|
||||||
|
idx.Decorate(ctx, pointer);
|
||||||
|
const Id object{ctx.OpLoad(def.sampled_type, pointer)};
|
||||||
|
idx.Decorate(ctx, object);
|
||||||
|
return object;
|
||||||
} else {
|
} else {
|
||||||
return ctx.OpLoad(def.sampled_type, def.id);
|
return ctx.OpLoad(def.sampled_type, def.id);
|
||||||
}
|
}
|
||||||
|
|
@ -208,9 +244,14 @@ Id TextureImage(EmitContext& ctx, IR::TextureInstInfo info, const IR::Value& ind
|
||||||
} else {
|
} else {
|
||||||
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
||||||
if (def.count > 1) {
|
if (def.count > 1) {
|
||||||
const Id idx{index.IsImmediate() ? ctx.Const(index.U32()) : ctx.Def(index)};
|
const DescriptorIndex idx{ctx, index};
|
||||||
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx)};
|
const Id ptr{ctx.OpAccessChain(def.pointer_type, def.id, idx.Value())};
|
||||||
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, ptr));
|
idx.Decorate(ctx, ptr);
|
||||||
|
const Id object{ctx.OpLoad(def.sampled_type, ptr)};
|
||||||
|
idx.Decorate(ctx, object);
|
||||||
|
const Id image{ctx.OpImage(def.image_type, object)};
|
||||||
|
idx.Decorate(ctx, image);
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, def.id));
|
return ctx.OpImage(def.image_type, ctx.OpLoad(def.sampled_type, def.id));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
|
@ -45,6 +48,7 @@ struct Profile {
|
||||||
bool support_scaled_attributes{};
|
bool support_scaled_attributes{};
|
||||||
bool support_multi_viewport{};
|
bool support_multi_viewport{};
|
||||||
bool support_geometry_streams{};
|
bool support_geometry_streams{};
|
||||||
|
bool support_sampled_image_array_nonuniform_indexing{};
|
||||||
|
|
||||||
bool warp_size_potentially_larger_than_guest{};
|
bool warp_size_potentially_larger_than_guest{};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -412,6 +412,8 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_,
|
||||||
.support_scaled_attributes = !device.MustEmulateScaledFormats(),
|
.support_scaled_attributes = !device.MustEmulateScaledFormats(),
|
||||||
.support_multi_viewport = device.SupportsMultiViewport(),
|
.support_multi_viewport = device.SupportsMultiViewport(),
|
||||||
.support_geometry_streams = device.AreTransformFeedbackGeometryStreamsSupported(),
|
.support_geometry_streams = device.AreTransformFeedbackGeometryStreamsSupported(),
|
||||||
|
.support_sampled_image_array_nonuniform_indexing =
|
||||||
|
device.IsSampledImageArrayNonUniformIndexingSupported(),
|
||||||
|
|
||||||
.warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(),
|
.warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
||||||
FEATURE(KHR, VariablePointer, VARIABLE_POINTERS, variable_pointer)
|
FEATURE(KHR, VariablePointer, VARIABLE_POINTERS, variable_pointer)
|
||||||
|
|
||||||
#define FOR_EACH_VK_FEATURE_1_2(FEATURE) \
|
#define FOR_EACH_VK_FEATURE_1_2(FEATURE) \
|
||||||
|
FEATURE(EXT, DescriptorIndexing, DESCRIPTOR_INDEXING, descriptor_indexing) \
|
||||||
FEATURE(EXT, HostQueryReset, HOST_QUERY_RESET, host_query_reset) \
|
FEATURE(EXT, HostQueryReset, HOST_QUERY_RESET, host_query_reset) \
|
||||||
FEATURE(KHR, 8BitStorage, 8BIT_STORAGE, bit8_storage) \
|
FEATURE(KHR, 8BitStorage, 8BIT_STORAGE, bit8_storage) \
|
||||||
FEATURE(KHR, TimelineSemaphore, TIMELINE_SEMAPHORE, timeline_semaphore)
|
FEATURE(KHR, TimelineSemaphore, TIMELINE_SEMAPHORE, timeline_semaphore)
|
||||||
|
|
@ -367,6 +368,10 @@ public:
|
||||||
return GetDriverID() != VK_DRIVER_ID_QUALCOMM_PROPRIETARY;
|
return GetDriverID() != VK_DRIVER_ID_QUALCOMM_PROPRIETARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsSampledImageArrayNonUniformIndexingSupported() const {
|
||||||
|
return features.descriptor_indexing.shaderSampledImageArrayNonUniformIndexing;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true if the device supports float64 natively.
|
/// Returns true if the device supports float64 natively.
|
||||||
bool IsFloat64Supported() const {
|
bool IsFloat64Supported() const {
|
||||||
return features.features.shaderFloat64;
|
return features.features.shaderFloat64;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue