mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-05 13:42:00 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 87c87642ed |
@@ -0,0 +1,34 @@
|
|||||||
|
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
|
||||||
|
index 2859ee1..766961f 100644
|
||||||
|
--- a/libavutil/hwcontext_vulkan.c
|
||||||
|
+++ b/libavutil/hwcontext_vulkan.c
|
||||||
|
@@ -1688,10 +1688,12 @@ static int setup_queue_families(AVHWDeviceContext *ctx, VkDeviceCreateInfo *cd)
|
||||||
|
|
||||||
|
hwctx->nb_qf = 0;
|
||||||
|
hwctx->queue_flags = 0;
|
||||||
|
+/* SD gamemode vkroots crash
|
||||||
|
#ifdef VK_KHR_internally_synchronized_queues
|
||||||
|
if (p->vkctx.extensions & FF_VK_EXT_INTERNAL_QUEUE_SYNC)
|
||||||
|
hwctx->queue_flags |= VK_DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR;
|
||||||
|
#endif
|
||||||
|
+*/
|
||||||
|
|
||||||
|
/* Pick each queue family to use. */
|
||||||
|
#define PICK_QF(type, vid_op) \
|
||||||
|
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
|
||||||
|
index b2e575c..5b3c9cf 100644
|
||||||
|
--- a/libavutil/vulkan.c
|
||||||
|
+++ b/libavutil/vulkan.c
|
||||||
|
@@ -574,10 +574,12 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, AVVulkanDeviceQueueFamily *qf,
|
||||||
|
e->qf = qf->idx;
|
||||||
|
VkDeviceQueueInfo2 qinfo = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2,
|
||||||
|
+/* SD gamemode vkroots crash
|
||||||
|
#ifdef VK_KHR_internally_synchronized_queues
|
||||||
|
.flags = internal_queue_sync ?
|
||||||
|
VK_DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR : 0,
|
||||||
|
#endif
|
||||||
|
+*/
|
||||||
|
.queueFamilyIndex = qf->idx,
|
||||||
|
.queueIndex = e->qi,
|
||||||
|
};
|
||||||
+3
-3
@@ -70,16 +70,16 @@
|
|||||||
"version": "v1.3.18"
|
"version": "v1.3.18"
|
||||||
},
|
},
|
||||||
"ffmpeg": {
|
"ffmpeg": {
|
||||||
"hash": "ed177621176b3961bdcaa339187d3a7688c1c8b060b79c4bb0257cbc67ad7021ae5d5adca5303b45625abbbe3d9aafdd87ce777b8690ac295290d744c875489a",
|
"hash": "68f46abf0d5dc47ab95083d59e273131a8df7948b82e62db00f00fa416e1d0bd24b799671b5a60752209bb2ac0f75295055ed0085c89a98113323cde23b69710",
|
||||||
"repo": "FFmpeg/FFmpeg",
|
"repo": "FFmpeg/FFmpeg",
|
||||||
"version": "c7b5f1537d"
|
"version": "6efe500d2e"
|
||||||
},
|
},
|
||||||
"ffmpeg-ci": {
|
"ffmpeg-ci": {
|
||||||
"ci": true,
|
"ci": true,
|
||||||
"name": "ffmpeg",
|
"name": "ffmpeg",
|
||||||
"package": "FFmpeg",
|
"package": "FFmpeg",
|
||||||
"repo": "crueter-ci/FFmpeg",
|
"repo": "crueter-ci/FFmpeg",
|
||||||
"version": "9.0.2-1790726865-946fcce07b"
|
"version": "9.0.1-1788120736-bf1b838f2a"
|
||||||
},
|
},
|
||||||
"fmt": {
|
"fmt": {
|
||||||
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
|
"hash": "f0da82c545b01692e9fd30fdfb613dbb8dd9716983dcd0ff19ac2a8d36f74beb5540ef38072fdecc1e34191b3682a8542ecbf3a61ef287dbba0a2679d4e023f2",
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import org.yuzu.yuzu_emu.model.Driver.Companion.toDriver
|
|||||||
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
import org.yuzu.yuzu_emu.utils.GpuDriverHelper
|
||||||
import org.yuzu.yuzu_emu.NativeLibrary
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
import org.yuzu.yuzu_emu.utils.GpuDriverMetadata
|
import org.yuzu.yuzu_emu.utils.GpuDriverMetadata
|
||||||
import org.yuzu.yuzu_emu.utils.DirectoryInitialization
|
|
||||||
import org.yuzu.yuzu_emu.utils.NativeConfig
|
import org.yuzu.yuzu_emu.utils.NativeConfig
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -147,11 +146,11 @@ class DriverViewModel : ViewModel() {
|
|||||||
private fun wipeGameShaders(game: Game) {
|
private fun wipeGameShaders(game: Game) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
val userDirectory = DirectoryInitialization.userDirectory
|
val externalFilesDir = YuzuApplication.appContext.getExternalFilesDir(null)
|
||||||
?: return@withContext
|
?: return@withContext
|
||||||
val shaderDir = File(
|
val shaderDir = File(
|
||||||
userDirectory +
|
externalFilesDir.absolutePath +
|
||||||
"/cache/shader/" + game.settingsName.lowercase()
|
"/shader/" + game.settingsName.lowercase()
|
||||||
)
|
)
|
||||||
if (shaderDir.exists()) {
|
if (shaderDir.exists()) {
|
||||||
shaderDir.deleteRecursively()
|
shaderDir.deleteRecursively()
|
||||||
|
|||||||
@@ -250,10 +250,9 @@ std::shared_ptr<FrontendApplet> FrontendAppletHolder::GetApplet(std::shared_ptr<
|
|||||||
return std::make_shared<PhotoViewer>(system, applet, mode, *frontend.photo_viewer);
|
return std::make_shared<PhotoViewer>(system, applet, mode, *frontend.photo_viewer);
|
||||||
case AppletId::NetConnect:
|
case AppletId::NetConnect:
|
||||||
return std::make_shared<NetConnect>(system, applet, mode, *frontend.net_connect);
|
return std::make_shared<NetConnect>(system, applet, mode, *frontend.net_connect);
|
||||||
case AppletId::None:
|
|
||||||
return nullptr;
|
|
||||||
default:
|
default:
|
||||||
UNIMPLEMENTED_MSG("No frontend implementation exists for applet_id={:02X} program_id={:016X}! Using stub applet.", static_cast<u8>(id), applet->program_id);
|
LOG_ERROR(Service_AM, "No backend implementation exists for applet_id={:02X} program_id={:016X}"
|
||||||
|
"Falling back to stub applet", static_cast<u8>(id), applet->program_id);
|
||||||
return std::make_shared<StubApplet>(system, applet, id, mode);
|
return std::make_shared<StubApplet>(system, applet, id, mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -757,7 +757,7 @@ struct Memory::Impl {
|
|||||||
};
|
};
|
||||||
auto& gpu = system.GPU();
|
auto& gpu = system.GPU();
|
||||||
gpu_device_memory->ApplyOpOnPointer(
|
gpu_device_memory->ApplyOpOnPointer(
|
||||||
p, scratch_buffers[core], [&](DAddr address) { gpu.InvalidateRegion(address, size, true); });
|
p, scratch_buffers[core], [&](DAddr address) { gpu.InvalidateRegion(address, size); });
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ struct HostTranslateInfo {
|
|||||||
///< passthrough shaders
|
///< passthrough shaders
|
||||||
bool support_conditional_barrier{}; ///< True when the device supports barriers in conditional
|
bool support_conditional_barrier{}; ///< True when the device supports barriers in conditional
|
||||||
///< control flow
|
///< control flow
|
||||||
bool support_attribute_texture_handle{}; ///< True when the host binds texture handles that
|
|
||||||
///< arrive as vertex attributes
|
|
||||||
|
|
||||||
void ApplyDescriptorLimitPolicy() noexcept {
|
void ApplyDescriptorLimitPolicy() noexcept {
|
||||||
if (min_ssbo_alignment == 0) {
|
if (min_ssbo_alignment == 0) {
|
||||||
|
|||||||
@@ -268,10 +268,6 @@ static inline u32 ReadCbufCached(Environment& env, u32 index, u32 offset) {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsAttributeHandle(const ConstBufferAddr& cbuf) {
|
|
||||||
return cbuf.index == ATTRIBUTE_HANDLE_CBUF_INDEX;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline u32 GetTextureHandleCached(Environment& env, const ConstBufferAddr& cbuf) {
|
static inline u32 GetTextureHandleCached(Environment& env, const ConstBufferAddr& cbuf) {
|
||||||
// Must all be uniquely different variables
|
// Must all be uniquely different variables
|
||||||
// If has secondary, then it will be cbuf.secondary_{index|offset}, else its 0.
|
// If has secondary, then it will be cbuf.secondary_{index|offset}, else its 0.
|
||||||
@@ -291,23 +287,14 @@ static inline u32 GetTextureHandleCached(Environment& env, const ConstBufferAddr
|
|||||||
|
|
||||||
// Cached variants of existing helpers
|
// Cached variants of existing helpers
|
||||||
static inline TextureType ReadTextureTypeCached(Environment& env, const ConstBufferAddr& cbuf) {
|
static inline TextureType ReadTextureTypeCached(Environment& env, const ConstBufferAddr& cbuf) {
|
||||||
if (IsAttributeHandle(cbuf)) {
|
|
||||||
return TextureType::Color2D;
|
|
||||||
}
|
|
||||||
return env.ReadTextureType(GetTextureHandleCached(env, cbuf));
|
return env.ReadTextureType(GetTextureHandleCached(env, cbuf));
|
||||||
}
|
}
|
||||||
static inline TexturePixelFormat ReadTexturePixelFormatCached(Environment& env,
|
static inline TexturePixelFormat ReadTexturePixelFormatCached(Environment& env,
|
||||||
const ConstBufferAddr& cbuf) {
|
const ConstBufferAddr& cbuf) {
|
||||||
if (IsAttributeHandle(cbuf)) {
|
|
||||||
return TexturePixelFormat::A8B8G8R8_UNORM;
|
|
||||||
}
|
|
||||||
return env.ReadTexturePixelFormat(GetTextureHandleCached(env, cbuf));
|
return env.ReadTexturePixelFormat(GetTextureHandleCached(env, cbuf));
|
||||||
}
|
}
|
||||||
static inline bool IsTexturePixelFormatIntegerCached(Environment& env,
|
static inline bool IsTexturePixelFormatIntegerCached(Environment& env,
|
||||||
const ConstBufferAddr& cbuf) {
|
const ConstBufferAddr& cbuf) {
|
||||||
if (IsAttributeHandle(cbuf)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return env.IsTexturePixelFormatInteger(GetTextureHandleCached(env, cbuf));
|
return env.IsTexturePixelFormatInteger(GetTextureHandleCached(env, cbuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,43 +466,15 @@ std::optional<ConstBufferAddr> TryGetConstBuffer(const IR::Inst* inst, Environme
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsAttributeSourcedHandle(const IR::Value& handle) {
|
|
||||||
if (handle.IsImmediate()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const IR::Inst* inst{handle.InstRecursive()};
|
|
||||||
if (inst->GetOpcode() == IR::Opcode::BitCastU32F32 && !inst->Arg(0).IsImmediate()) {
|
|
||||||
inst = inst->Arg(0).InstRecursive();
|
|
||||||
}
|
|
||||||
return inst->GetOpcode() == IR::Opcode::GetAttribute ||
|
|
||||||
inst->GetOpcode() == IR::Opcode::GetAttributeU32;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureInst MakeInst(Environment& env, IR::Block* block, IR::Inst& inst, const HostTranslateInfo& host_info) {
|
TextureInst MakeInst(Environment& env, IR::Block* block, IR::Inst& inst, const HostTranslateInfo& host_info) {
|
||||||
ConstBufferAddr addr;
|
ConstBufferAddr addr;
|
||||||
if (IsBindless(inst)) {
|
if (IsBindless(inst)) {
|
||||||
const std::optional<ConstBufferAddr> track_addr{TrackCached(inst.Arg(0), env, host_info)};
|
const std::optional<ConstBufferAddr> track_addr{TrackCached(inst.Arg(0), env, host_info)};
|
||||||
|
|
||||||
if (track_addr) {
|
if (!track_addr) {
|
||||||
addr = *track_addr;
|
|
||||||
} else if (host_info.support_attribute_texture_handle &&
|
|
||||||
IsAttributeSourcedHandle(inst.Arg(0))) {
|
|
||||||
// The handle travels with the vertices (sprite batches pick the texture per quad), so
|
|
||||||
// there is no constant buffer to read it from. The host binds the handle of each run
|
|
||||||
// of vertices that share one.
|
|
||||||
addr = ConstBufferAddr{
|
|
||||||
.index = ATTRIBUTE_HANDLE_CBUF_INDEX,
|
|
||||||
.offset = 0,
|
|
||||||
.shift_left = 0,
|
|
||||||
.secondary_index = 0,
|
|
||||||
.secondary_offset = 0,
|
|
||||||
.secondary_shift_left = 0,
|
|
||||||
.dynamic_offset = {},
|
|
||||||
.count = 1,
|
|
||||||
.has_secondary = false,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
throw NotImplementedException("Failed to track bindless texture constant buffer");
|
throw NotImplementedException("Failed to track bindless texture constant buffer");
|
||||||
|
} else {
|
||||||
|
addr = *track_addr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addr = ConstBufferAddr{
|
addr = ConstBufferAddr{
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ enum class TextureType : u32 {
|
|||||||
};
|
};
|
||||||
constexpr u32 NUM_TEXTURE_TYPES = 9;
|
constexpr u32 NUM_TEXTURE_TYPES = 9;
|
||||||
|
|
||||||
/// Constant buffer index marking a texture handle that the shader receives as a vertex attribute
|
|
||||||
/// instead of reading it from a constant buffer. The host supplies the handle of each draw run.
|
|
||||||
constexpr u32 ATTRIBUTE_HANDLE_CBUF_INDEX = 0xFFFF;
|
|
||||||
|
|
||||||
enum class TexturePixelFormat {
|
enum class TexturePixelFormat {
|
||||||
A8B8G8R8_UNORM,
|
A8B8G8R8_UNORM,
|
||||||
A8B8G8R8_SNORM,
|
A8B8G8R8_SNORM,
|
||||||
|
|||||||
+3
-13
@@ -226,17 +226,7 @@ struct GPU::Impl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be invalidated
|
/// Notify rasterizer that any caches of the specified region should be invalidated
|
||||||
void InvalidateRegion(DAddr addr, u64 size, bool preserve_gpu_writes) {
|
void InvalidateRegion(DAddr addr, u64 size) {
|
||||||
VideoCore::RasterizerInterface* rasterizer = renderer->ReadRasterizer();
|
|
||||||
if (preserve_gpu_writes && rasterizer->MustFlushRegion(addr, size, VideoCommon::CacheType::BufferCache)) {
|
|
||||||
const u64 fence = RequestSyncOperation([rasterizer, addr, size] {
|
|
||||||
rasterizer->FlushRegion(addr, size, VideoCommon::CacheType::BufferCache);
|
|
||||||
rasterizer->OnCacheInvalidation(addr, size);
|
|
||||||
});
|
|
||||||
gpu_thread.TickGPU(is_async);
|
|
||||||
WaitForSyncOperation(fence);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gpu_thread.InvalidateRegion(addr, size);
|
gpu_thread.InvalidateRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,8 +518,8 @@ void GPU::FlushRegion(DAddr addr, u64 size) {
|
|||||||
impl->FlushRegion(addr, size);
|
impl->FlushRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::InvalidateRegion(DAddr addr, u64 size, bool preserve_gpu_writes) {
|
void GPU::InvalidateRegion(DAddr addr, u64 size) {
|
||||||
impl->InvalidateRegion(addr, size, preserve_gpu_writes);
|
impl->InvalidateRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPU::OnCPUWrite(DAddr addr, u64 size) {
|
bool GPU::OnCPUWrite(DAddr addr, u64 size) {
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ public:
|
|||||||
void FlushRegion(DAddr addr, u64 size);
|
void FlushRegion(DAddr addr, u64 size);
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be invalidated
|
/// Notify rasterizer that any caches of the specified region should be invalidated
|
||||||
void InvalidateRegion(DAddr addr, u64 size, bool preserve_gpu_writes = false);
|
void InvalidateRegion(DAddr addr, u64 size);
|
||||||
|
|
||||||
/// Notify rasterizer that CPU is trying to write this area. It returns true if the area is
|
/// Notify rasterizer that CPU is trying to write this area. It returns true if the area is
|
||||||
/// sensible, false otherwise, addr and size must be a valid combination
|
/// sensible, false otherwise, addr and size must be a valid combination
|
||||||
|
|||||||
@@ -276,9 +276,6 @@ GraphicsPipeline::GraphicsPipeline(
|
|||||||
num_textures += Shader::NumDescriptors(info->texture_descriptors);
|
num_textures += Shader::NumDescriptors(info->texture_descriptors);
|
||||||
num_image_elements += Shader::NumDescriptors(info->texture_descriptors);
|
num_image_elements += Shader::NumDescriptors(info->texture_descriptors);
|
||||||
num_image_elements += Shader::NumDescriptors(info->image_descriptors);
|
num_image_elements += Shader::NumDescriptors(info->image_descriptors);
|
||||||
for (const auto& desc : info->texture_descriptors) {
|
|
||||||
uses_attribute_handle |= desc.cbuf_index == Shader::ATTRIBUTE_HANDLE_CBUF_INDEX;
|
|
||||||
}
|
|
||||||
num_descriptor_entries += NumDescriptorEntries(*info);
|
num_descriptor_entries += NumDescriptorEntries(*info);
|
||||||
}
|
}
|
||||||
fragment_has_color0_output = stage_infos[NUM_STAGES - 1].stores_frag_color[0];
|
fragment_has_color0_output = stage_infos[NUM_STAGES - 1].stores_frag_color[0];
|
||||||
@@ -378,9 +375,6 @@ bool GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|||||||
}
|
}
|
||||||
const auto& cbufs{maxwell3d->state.shader_stages[stage].const_buffers};
|
const auto& cbufs{maxwell3d->state.shader_stages[stage].const_buffers};
|
||||||
const auto read_handle{[&](const auto& desc, u32 index) {
|
const auto read_handle{[&](const auto& desc, u32 index) {
|
||||||
if (desc.cbuf_index == Shader::ATTRIBUTE_HANDLE_CBUF_INDEX) {
|
|
||||||
return TexturePair(attribute_handle, via_header_index);
|
|
||||||
}
|
|
||||||
ASSERT(cbufs[desc.cbuf_index].enabled);
|
ASSERT(cbufs[desc.cbuf_index].enabled);
|
||||||
const u32 index_offset{index << desc.size_shift};
|
const u32 index_offset{index << desc.size_shift};
|
||||||
const u32 offset{desc.cbuf_offset + index_offset};
|
const u32 offset{desc.cbuf_offset + index_offset};
|
||||||
|
|||||||
@@ -110,16 +110,6 @@ public:
|
|||||||
return configure_func(this, is_indexed);
|
return configure_func(this, is_indexed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// True when a shader samples a texture whose handle arrives as a vertex attribute.
|
|
||||||
[[nodiscard]] bool UsesAttributeHandle() const noexcept {
|
|
||||||
return uses_attribute_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Handle bound to those textures by the next Configure.
|
|
||||||
void SetAttributeHandle(u32 handle) noexcept {
|
|
||||||
attribute_handle = handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] GraphicsPipeline* Next(const GraphicsPipelineCacheKey& current_key) noexcept {
|
[[nodiscard]] GraphicsPipeline* Next(const GraphicsPipelineCacheKey& current_key) noexcept {
|
||||||
if (key == current_key) {
|
if (key == current_key) {
|
||||||
return this;
|
return this;
|
||||||
@@ -178,8 +168,6 @@ private:
|
|||||||
u32 num_descriptor_entries{};
|
u32 num_descriptor_entries{};
|
||||||
size_t num_image_elements{};
|
size_t num_image_elements{};
|
||||||
u32 num_textures{};
|
u32 num_textures{};
|
||||||
u32 attribute_handle{};
|
|
||||||
bool uses_attribute_handle{};
|
|
||||||
bool fragment_has_color0_output{};
|
bool fragment_has_color0_output{};
|
||||||
|
|
||||||
vk::DescriptorSetLayout descriptor_set_layout;
|
vk::DescriptorSetLayout descriptor_set_layout;
|
||||||
|
|||||||
@@ -479,7 +479,6 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_,
|
|||||||
.support_viewport_index_layer = device.IsExtShaderViewportIndexLayerSupported(),
|
.support_viewport_index_layer = device.IsExtShaderViewportIndexLayerSupported(),
|
||||||
.support_geometry_shader_passthrough = device.IsNvGeometryShaderPassthroughSupported(),
|
.support_geometry_shader_passthrough = device.IsNvGeometryShaderPassthroughSupported(),
|
||||||
.support_conditional_barrier = device.SupportsConditionalBarriers(),
|
.support_conditional_barrier = device.SupportsConditionalBarriers(),
|
||||||
.support_attribute_texture_handle = true,
|
|
||||||
};
|
};
|
||||||
host_info.ApplyDescriptorLimitPolicy();
|
host_info.ApplyDescriptorLimitPolicy();
|
||||||
|
|
||||||
|
|||||||
@@ -248,15 +248,6 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) {
|
|||||||
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
||||||
// update engine as channel may be different.
|
// update engine as channel may be different.
|
||||||
pipeline->SetEngine(maxwell3d, gpu_memory);
|
pipeline->SetEngine(maxwell3d, gpu_memory);
|
||||||
attribute_handle_pipeline = nullptr;
|
|
||||||
attribute_handle_runs.clear();
|
|
||||||
if (split_attribute_handles && pipeline->UsesAttributeHandle()) {
|
|
||||||
CollectAttributeHandleRuns(is_indexed);
|
|
||||||
if (!attribute_handle_runs.empty()) {
|
|
||||||
attribute_handle_pipeline = pipeline;
|
|
||||||
pipeline->SetAttributeHandle(attribute_handle_runs.front().handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!pipeline->Configure(is_indexed))
|
if (!pipeline->Configure(is_indexed))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -268,110 +259,22 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) {
|
|||||||
draw_func();
|
draw_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::CollectAttributeHandleRuns(bool is_indexed) {
|
|
||||||
using VertexAttribute = Maxwell::VertexAttribute;
|
|
||||||
const auto& regs = maxwell3d->regs;
|
|
||||||
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
|
||||||
const u32 total = is_indexed ? draw_state.index_buffer.count : draw_state.vertex_buffer.count;
|
|
||||||
if (total == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// The handle is an integer attribute; sprite batches repeat it on every vertex of a quad.
|
|
||||||
const VertexAttribute* source{};
|
|
||||||
for (const auto& attr : regs.vertex_attrib_format) {
|
|
||||||
if (attr.constant || attr.size == VertexAttribute::Size::Invalid) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (attr.type == VertexAttribute::Type::UInt || attr.type == VertexAttribute::Type::SInt) {
|
|
||||||
source = &attr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const auto& stream = regs.vertex_streams[source ? source->buffer.Value() : 0];
|
|
||||||
if (!source || !stream.IsEnabled()) {
|
|
||||||
attribute_handle_runs.push_back({0, total, 0});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Only plain triangle lists are split; anything else keeps the handle of its first vertex.
|
|
||||||
const u32 primitive_size =
|
|
||||||
draw_state.topology == Maxwell::PrimitiveTopology::Triangles ? 3 : total;
|
|
||||||
const GPUVAddr base_address = stream.Address() + source->offset;
|
|
||||||
const auto read_handle = [&](u32 position) {
|
|
||||||
u32 vertex;
|
|
||||||
if (is_indexed) {
|
|
||||||
const auto& index_buffer = draw_state.index_buffer;
|
|
||||||
const GPUVAddr address =
|
|
||||||
index_buffer.IndexStart() + size_t{position} * index_buffer.FormatSizeInBytes();
|
|
||||||
u32 index{};
|
|
||||||
gpu_memory->ReadBlockUnsafe(address, &index, index_buffer.FormatSizeInBytes());
|
|
||||||
vertex = static_cast<u32>(draw_state.base_index + index);
|
|
||||||
} else {
|
|
||||||
vertex = draw_state.vertex_buffer.first + position;
|
|
||||||
}
|
|
||||||
return gpu_memory->Read<u32>(base_address + static_cast<GPUVAddr>(vertex) * stream.stride);
|
|
||||||
};
|
|
||||||
for (u32 position = 0; position + primitive_size <= total; position += primitive_size) {
|
|
||||||
const u32 handle = read_handle(position);
|
|
||||||
if (!attribute_handle_runs.empty() && attribute_handle_runs.back().handle == handle) {
|
|
||||||
attribute_handle_runs.back().count += primitive_size;
|
|
||||||
} else {
|
|
||||||
attribute_handle_runs.push_back({position, primitive_size, handle});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (attribute_handle_runs.empty()) {
|
|
||||||
attribute_handle_runs.push_back({0, total, read_handle(0)});
|
|
||||||
} else {
|
|
||||||
const u32 covered = attribute_handle_runs.back().first + attribute_handle_runs.back().count;
|
|
||||||
if (covered < total) {
|
|
||||||
attribute_handle_runs.back().count += total - covered;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) {
|
void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) {
|
||||||
split_attribute_handles = true;
|
|
||||||
SCOPE_EXIT {
|
|
||||||
split_attribute_handles = false;
|
|
||||||
};
|
|
||||||
PrepareDraw(is_indexed, [this, is_indexed, instance_count] {
|
PrepareDraw(is_indexed, [this, is_indexed, instance_count] {
|
||||||
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
||||||
const u32 num_instances{instance_count};
|
const u32 num_instances{instance_count};
|
||||||
const DrawParams draw_params{MakeDrawParams(draw_state, num_instances, is_indexed)};
|
const DrawParams draw_params{MakeDrawParams(draw_state, num_instances, is_indexed)};
|
||||||
|
|
||||||
const auto record_draw = [this](const DrawParams& params) {
|
scheduler.Record([draw_params](vk::CommandBuffer cmdbuf) {
|
||||||
scheduler.Record([params](vk::CommandBuffer cmdbuf) {
|
if (draw_params.is_indexed) {
|
||||||
if (params.is_indexed) {
|
cmdbuf.DrawIndexed(draw_params.num_vertices, draw_params.num_instances,
|
||||||
cmdbuf.DrawIndexed(params.num_vertices, params.num_instances,
|
draw_params.first_index, draw_params.base_vertex,
|
||||||
params.first_index, params.base_vertex,
|
draw_params.base_instance);
|
||||||
params.base_instance);
|
} else {
|
||||||
} else {
|
cmdbuf.Draw(draw_params.num_vertices, draw_params.num_instances,
|
||||||
cmdbuf.Draw(params.num_vertices, params.num_instances, params.base_vertex,
|
draw_params.base_vertex, draw_params.base_instance);
|
||||||
params.base_instance);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
if (attribute_handle_pipeline && attribute_handle_runs.size() > 1) {
|
|
||||||
// The first run is already configured, each further one binds its own texture.
|
|
||||||
for (size_t i = 0; i < attribute_handle_runs.size(); ++i) {
|
|
||||||
const AttributeHandleRun& run = attribute_handle_runs[i];
|
|
||||||
if (i != 0) {
|
|
||||||
attribute_handle_pipeline->SetAttributeHandle(run.handle);
|
|
||||||
if (!attribute_handle_pipeline->Configure(is_indexed)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DrawParams run_params = draw_params;
|
|
||||||
run_params.num_vertices = run.count;
|
|
||||||
if (is_indexed) {
|
|
||||||
run_params.first_index += run.first;
|
|
||||||
} else {
|
|
||||||
run_params.base_vertex += run.first;
|
|
||||||
}
|
|
||||||
record_draw(run_params);
|
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
record_draw(draw_params);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Log draw call
|
// Log draw call
|
||||||
if (GPU::Logging::IsActive() &&
|
if (GPU::Logging::IsActive() &&
|
||||||
|
|||||||
@@ -157,20 +157,6 @@ private:
|
|||||||
template <typename Func>
|
template <typename Func>
|
||||||
void PrepareDraw(bool is_indexed, Func&&);
|
void PrepareDraw(bool is_indexed, Func&&);
|
||||||
|
|
||||||
/// A stretch of a draw whose vertices all carry the same texture handle.
|
|
||||||
struct AttributeHandleRun {
|
|
||||||
u32 first;
|
|
||||||
u32 count;
|
|
||||||
u32 handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Splits the current draw wherever the texture handle carried in the vertex data changes.
|
|
||||||
void CollectAttributeHandleRuns(bool is_indexed);
|
|
||||||
|
|
||||||
std::vector<AttributeHandleRun> attribute_handle_runs;
|
|
||||||
GraphicsPipeline* attribute_handle_pipeline{};
|
|
||||||
bool split_attribute_handles{};
|
|
||||||
|
|
||||||
void FlushWork();
|
void FlushWork();
|
||||||
|
|
||||||
void UpdateDynamicStates();
|
void UpdateDynamicStates();
|
||||||
|
|||||||
+11
-15
@@ -12,29 +12,25 @@ namespace Yuzu {
|
|||||||
|
|
||||||
inline bool ContainsAllWords(const QString& haystack, const QString& userinput) {
|
inline bool ContainsAllWords(const QString& haystack, const QString& userinput) {
|
||||||
const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts);
|
const QStringList userinput_split = userinput.split(QLatin1Char{' '}, Qt::SkipEmptyParts);
|
||||||
return std::all_of(userinput_split.begin(), userinput_split.end(), [&haystack](const QString& s) {
|
return std::all_of(userinput_split.begin(), userinput_split.end(),
|
||||||
return haystack.contains(s);
|
[&haystack](const QString& s) { return haystack.contains(s); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool FilterMatches(const QString& filter, const QStandardItem* item) {
|
inline bool FilterMatches(const QString& filter, const QStandardItem* item) {
|
||||||
if (filter.isEmpty())
|
if (filter.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
auto const sluggify = [](const QString& s) {
|
|
||||||
QString o(s.normalized(QString::NormalizationForm_D).toLower());
|
|
||||||
return o.replace(QRegularExpression(QStringLiteral("[^a-z\\s]")), QStringLiteral(""));
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto norm_filter = sluggify(filter);
|
|
||||||
const auto program_id = item->data(GameListItemPath::ProgramIdRole).toULongLong();
|
const auto program_id = item->data(GameListItemPath::ProgramIdRole).toULongLong();
|
||||||
const QString file_path = sluggify(item->data(GameListItemPath::FullPathRole).toString());
|
|
||||||
const QString file_title = sluggify(item->data(GameListItemPath::TitleRole).toString());
|
const QString file_path = item->data(GameListItemPath::FullPathRole).toString().toLower();
|
||||||
|
const QString file_title = item->data(GameListItemPath::TitleRole).toString().toLower();
|
||||||
const QString file_program_id = QStringLiteral("%1").arg(program_id, 16, 16, QLatin1Char{'0'});
|
const QString file_program_id = QStringLiteral("%1").arg(program_id, 16, 16, QLatin1Char{'0'});
|
||||||
const QString file_name = sluggify(file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title);
|
|
||||||
return (ContainsAllWords(file_name, norm_filter)
|
const QString file_name =
|
||||||
|| ContainsAllWords(file_title, norm_filter))
|
file_path.mid(file_path.lastIndexOf(QLatin1Char{'/'}) + 1) + QLatin1Char{' '} + file_title;
|
||||||
|| (file_program_id.size() == 16 && file_program_id.contains(norm_filter));
|
|
||||||
|
return Yuzu::ContainsAllWords(file_name, filter) ||
|
||||||
|
(file_program_id.size() == 16 && file_program_id.contains(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Yuzu
|
} // namespace Yuzu
|
||||||
|
|||||||
Reference in New Issue
Block a user