mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-28 18:34:19 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c246f02697 | |||
| f6e7686038 | |||
| 1dcc574591 | |||
| 5c20f244c9 |
+1
-1
@@ -238,7 +238,7 @@ option(YUZU_USE_BUNDLED_SIRIT "Download bundled sirit" ${BUNDLED_SIRIT_DEFAULT})
|
|||||||
# FreeBSD 15+ has libusb, versions below should disable it
|
# FreeBSD 15+ has libusb, versions below should disable it
|
||||||
cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "WIN32 OR LINUX OR FREEBSD OR APPLE" OFF)
|
cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "WIN32 OR LINUX OR FREEBSD OR APPLE" OFF)
|
||||||
|
|
||||||
cmake_dependent_option(ENABLE_OPENGL "Enable OpenGL" ON "NOT (WIN32 AND ARCHITECTURE_arm64) AND NOT APPLE" OFF)
|
cmake_dependent_option(ENABLE_OPENGL "Enable OpenGL" ON "NOT (WIN32 AND ARCHITECTURE_arm64) AND NOT APPLE AND NOT ANDROID" OFF)
|
||||||
mark_as_advanced(FORCE ENABLE_OPENGL)
|
mark_as_advanced(FORCE ENABLE_OPENGL)
|
||||||
|
|
||||||
option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON)
|
option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON)
|
||||||
|
|||||||
+1
-1
@@ -76,7 +76,7 @@ The following options are desktop only.
|
|||||||
|
|
||||||
- `ENABLE_LIBUSB` (ON) Enable the use of the libusb input backend (HIGHLY RECOMMENDED)
|
- `ENABLE_LIBUSB` (ON) Enable the use of the libusb input backend (HIGHLY RECOMMENDED)
|
||||||
- `ENABLE_OPENGL` (ON) Enable the OpenGL graphics backend
|
- `ENABLE_OPENGL` (ON) Enable the OpenGL graphics backend
|
||||||
- Unavailable on Windows/ARM64
|
- Unavailable on Windows/ARM64 and on Android
|
||||||
- You probably shouldn't turn this off.
|
- You probably shouldn't turn this off.
|
||||||
|
|
||||||
### Qt
|
### Qt
|
||||||
|
|||||||
Vendored
+1
@@ -11,6 +11,7 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <algorithm>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
namespace Tz {
|
namespace Tz {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <cstdlib>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <llvm/Demangle/Demangle.h>
|
#include <llvm/Demangle/Demangle.h>
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ private:
|
|||||||
|
|
||||||
ConnectionState(boost::asio::ip::tcp::socket&& client_socket_, async_pipe signal_pipe_, Kernel::KernelCore& kernel)
|
ConnectionState(boost::asio::ip::tcp::socket&& client_socket_, async_pipe signal_pipe_, Kernel::KernelCore& kernel)
|
||||||
: client_socket{std::move(client_socket_)}
|
: client_socket{std::move(client_socket_)}
|
||||||
, signal_pipe{signal_pipe_}
|
, signal_pipe{std::move(signal_pipe_)}
|
||||||
, active_thread{kernel, nullptr}
|
, active_thread{kernel, nullptr}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -1021,6 +1021,9 @@ Result KProcess::Run(KernelCore& kernel, s32 priority, size_t stack_size) {
|
|||||||
|
|
||||||
// Suspend for debug, if we should.
|
// Suspend for debug, if we should.
|
||||||
if (kernel.System().DebuggerEnabled()) {
|
if (kernel.System().DebuggerEnabled()) {
|
||||||
|
LOG_INFO(Debug_GDBStub,
|
||||||
|
"GDB stub enabled; suspending guest process until a debugger continues execution on port {}",
|
||||||
|
Settings::values.gdbstub_port.GetValue());
|
||||||
main_thread->RequestSuspend(kernel, SuspendType::Debug);
|
main_thread->RequestSuspend(kernel, SuspendType::Debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -492,6 +492,9 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct
|
|||||||
if (ctx.uses_nonuniform_storage_texel_buffer) {
|
if (ctx.uses_nonuniform_storage_texel_buffer) {
|
||||||
ctx.AddCapability(spv::Capability::StorageTexelBufferArrayNonUniformIndexing);
|
ctx.AddCapability(spv::Capability::StorageTexelBufferArrayNonUniformIndexing);
|
||||||
}
|
}
|
||||||
|
if (ctx.uses_nonuniform_storage_buffer) {
|
||||||
|
ctx.AddCapability(spv::Capability::StorageBufferArrayNonUniformIndexing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
// 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
|
||||||
|
|
||||||
#include <bit>
|
|
||||||
|
|
||||||
#include "shader_recompiler/backend/spirv/emit_spirv.h"
|
#include "shader_recompiler/backend/spirv/emit_spirv.h"
|
||||||
#include "shader_recompiler/backend/spirv/emit_spirv_instructions.h"
|
#include "shader_recompiler/backend/spirv/emit_spirv_instructions.h"
|
||||||
#include "shader_recompiler/backend/spirv/spirv_emit_context.h"
|
#include "shader_recompiler/backend/spirv/spirv_emit_context.h"
|
||||||
@@ -23,29 +21,13 @@ Id SharedPointer(EmitContext& ctx, Id offset, u32 index_offset = 0) {
|
|||||||
: ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index);
|
: ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id StorageIndex(EmitContext& ctx, const IR::Value& offset, size_t element_size) {
|
|
||||||
if (offset.IsImmediate()) {
|
|
||||||
const u32 imm_offset{static_cast<u32>(offset.U32() / element_size)};
|
|
||||||
return ctx.Const(imm_offset);
|
|
||||||
}
|
|
||||||
const u32 shift{static_cast<u32>(std::countr_zero(element_size))};
|
|
||||||
const Id index{ctx.Def(offset)};
|
|
||||||
if (shift == 0) {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
const Id shift_id{ctx.Const(shift)};
|
|
||||||
return ctx.OpShiftRightLogical(ctx.U32[1], index, shift_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Id StoragePointer(EmitContext& ctx, const StorageTypeDefinition& type_def,
|
Id StoragePointer(EmitContext& ctx, const StorageTypeDefinition& type_def,
|
||||||
Id StorageDefinitions::*member_ptr, const IR::Value& binding,
|
Id StorageDefinitions::*member_ptr, const IR::Value& binding,
|
||||||
const IR::Value& offset, size_t element_size) {
|
const IR::Value& offset, size_t element_size) {
|
||||||
if (!binding.IsImmediate()) {
|
if (!binding.IsImmediate()) {
|
||||||
throw NotImplementedException("Dynamic storage buffer indexing");
|
throw NotImplementedException("Dynamic storage buffer indexing");
|
||||||
}
|
}
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].*member_ptr};
|
return ctx.StoragePointer(binding.U32(), ctx.Def(offset), type_def, static_cast<u32>(element_size), member_ptr);
|
||||||
const Id index{StorageIndex(ctx, offset, element_size)};
|
|
||||||
return ctx.OpAccessChain(type_def.element, ssbo, ctx.u32_zero_value, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<Id, Id> AtomicArgs(EmitContext& ctx) {
|
std::pair<Id, Id> AtomicArgs(EmitContext& ctx) {
|
||||||
@@ -216,16 +198,14 @@ Id EmitStorageAtomicUMax32(EmitContext& ctx, const IR::Value& binding, const IR:
|
|||||||
|
|
||||||
Id EmitStorageAtomicInc32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicInc32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
return ctx.OpFunctionCall(ctx.U32[1], ctx.increment_cas_ssbo, pointer, value);
|
||||||
return ctx.OpFunctionCall(ctx.U32[1], ctx.increment_cas_ssbo, base_index, value, ssbo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitStorageAtomicDec32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicDec32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
return ctx.OpFunctionCall(ctx.U32[1], ctx.decrement_cas_ssbo, pointer, value);
|
||||||
return ctx.OpFunctionCall(ctx.U32[1], ctx.decrement_cas_ssbo, base_index, value, ssbo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitStorageAtomicAnd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicAnd32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
@@ -364,56 +344,49 @@ Id EmitStorageAtomicExchange32x2(EmitContext& ctx, const IR::Value& binding,
|
|||||||
|
|
||||||
Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicAddF32(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
return ctx.OpFunctionCall(ctx.F32[1], ctx.f32_add_cas, pointer, value);
|
||||||
return ctx.OpFunctionCall(ctx.F32[1], ctx.f32_add_cas, base_index, value, ssbo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitStorageAtomicAddF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicAddF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
const Id result{ctx.OpFunctionCall(ctx.F16[2], ctx.f16x2_add_cas, pointer, value)};
|
||||||
const Id result{ctx.OpFunctionCall(ctx.F16[2], ctx.f16x2_add_cas, base_index, value, ssbo)};
|
|
||||||
return ctx.OpBitcast(ctx.U32[1], result);
|
return ctx.OpBitcast(ctx.U32[1], result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitStorageAtomicAddF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicAddF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
const Id result{ctx.OpFunctionCall(ctx.F32[2], ctx.f32x2_add_cas, pointer, value)};
|
||||||
const Id result{ctx.OpFunctionCall(ctx.F32[2], ctx.f32x2_add_cas, base_index, value, ssbo)};
|
|
||||||
return ctx.OpPackHalf2x16(ctx.U32[1], result);
|
return ctx.OpPackHalf2x16(ctx.U32[1], result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitStorageAtomicMinF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicMinF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
const Id result{ctx.OpFunctionCall(ctx.F16[2], ctx.f16x2_min_cas, pointer, value)};
|
||||||
const Id result{ctx.OpFunctionCall(ctx.F16[2], ctx.f16x2_min_cas, base_index, value, ssbo)};
|
|
||||||
return ctx.OpBitcast(ctx.U32[1], result);
|
return ctx.OpBitcast(ctx.U32[1], result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitStorageAtomicMinF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicMinF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
const Id result{ctx.OpFunctionCall(ctx.F32[2], ctx.f32x2_min_cas, pointer, value)};
|
||||||
const Id result{ctx.OpFunctionCall(ctx.F32[2], ctx.f32x2_min_cas, base_index, value, ssbo)};
|
|
||||||
return ctx.OpPackHalf2x16(ctx.U32[1], result);
|
return ctx.OpPackHalf2x16(ctx.U32[1], result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitStorageAtomicMaxF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicMaxF16x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
const Id result{ctx.OpFunctionCall(ctx.F16[2], ctx.f16x2_max_cas, pointer, value)};
|
||||||
const Id result{ctx.OpFunctionCall(ctx.F16[2], ctx.f16x2_max_cas, base_index, value, ssbo)};
|
|
||||||
return ctx.OpBitcast(ctx.U32[1], result);
|
return ctx.OpBitcast(ctx.U32[1], result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Id EmitStorageAtomicMaxF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id EmitStorageAtomicMaxF32x2(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
Id value) {
|
Id value) {
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].U32};
|
const Id pointer{StoragePointer(ctx, ctx.storage_types.U32, &StorageDefinitions::U32, binding, offset, sizeof(u32))};
|
||||||
const Id base_index{StorageIndex(ctx, offset, sizeof(u32))};
|
const Id result{ctx.OpFunctionCall(ctx.F32[2], ctx.f32x2_max_cas, pointer, value)};
|
||||||
const Id result{ctx.OpFunctionCall(ctx.F32[2], ctx.f32x2_max_cas, base_index, value, ssbo)};
|
|
||||||
return ctx.OpPackHalf2x16(ctx.U32[1], result);
|
return ctx.OpPackHalf2x16(ctx.U32[1], result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,46 +4,33 @@
|
|||||||
// 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
|
||||||
|
|
||||||
#include <bit>
|
|
||||||
|
|
||||||
#include "shader_recompiler/backend/spirv/emit_spirv.h"
|
#include "shader_recompiler/backend/spirv/emit_spirv.h"
|
||||||
#include "shader_recompiler/backend/spirv/emit_spirv_instructions.h"
|
#include "shader_recompiler/backend/spirv/emit_spirv_instructions.h"
|
||||||
#include "shader_recompiler/backend/spirv/spirv_emit_context.h"
|
#include "shader_recompiler/backend/spirv/spirv_emit_context.h"
|
||||||
|
|
||||||
namespace Shader::Backend::SPIRV {
|
namespace Shader::Backend::SPIRV {
|
||||||
namespace {
|
namespace {
|
||||||
Id StorageIndex(EmitContext& ctx, const IR::Value& offset, size_t element_size,
|
Id StorageByteOffset(EmitContext& ctx, const IR::Value& offset, size_t element_size, u32 index_offset) {
|
||||||
u32 index_offset = 0) {
|
Id byte_offset{ctx.Def(offset)};
|
||||||
if (offset.IsImmediate()) {
|
|
||||||
const u32 imm_offset{static_cast<u32>(offset.U32() / element_size) + index_offset};
|
|
||||||
return ctx.Const(imm_offset);
|
|
||||||
}
|
|
||||||
const u32 shift{static_cast<u32>(std::countr_zero(element_size))};
|
|
||||||
Id index{ctx.Def(offset)};
|
|
||||||
if (shift != 0) {
|
|
||||||
const Id shift_id{ctx.Const(shift)};
|
|
||||||
index = ctx.OpShiftRightLogical(ctx.U32[1], index, shift_id);
|
|
||||||
}
|
|
||||||
if (index_offset != 0) {
|
if (index_offset != 0) {
|
||||||
index = ctx.OpIAdd(ctx.U32[1], index, ctx.Const(index_offset));
|
byte_offset = ctx.OpIAdd(ctx.U32[1], byte_offset, ctx.Const(static_cast<u32>(index_offset * element_size)));
|
||||||
}
|
}
|
||||||
return index;
|
return byte_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
Id StoragePointer(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
Id StoragePointer(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset,
|
||||||
const StorageTypeDefinition& type_def, size_t element_size,
|
const StorageTypeDefinition& type_def, size_t element_size,
|
||||||
Id StorageDefinitions::*member_ptr, u32 index_offset = 0) {
|
Id StorageDefinitions::* member_ptr, u32 index_offset = 0) {
|
||||||
if (!binding.IsImmediate()) {
|
if (!binding.IsImmediate()) {
|
||||||
throw NotImplementedException("Dynamic storage buffer indexing");
|
throw NotImplementedException("Dynamic storage buffer indexing");
|
||||||
}
|
}
|
||||||
const Id ssbo{ctx.ssbos[binding.U32()].*member_ptr};
|
const Id byte_offset{StorageByteOffset(ctx, offset, element_size, index_offset)};
|
||||||
const Id index{StorageIndex(ctx, offset, element_size, index_offset)};
|
return ctx.StoragePointer(binding.U32(), byte_offset, type_def, static_cast<u32>(element_size), member_ptr);
|
||||||
return ctx.OpAccessChain(type_def.element, ssbo, ctx.u32_zero_value, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Id LoadStorage(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, Id result_type,
|
Id LoadStorage(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, Id result_type,
|
||||||
const StorageTypeDefinition& type_def, size_t element_size,
|
const StorageTypeDefinition& type_def, size_t element_size,
|
||||||
Id StorageDefinitions::*member_ptr, u32 index_offset = 0) {
|
Id StorageDefinitions::* member_ptr, u32 index_offset = 0) {
|
||||||
const Id pointer{
|
const Id pointer{
|
||||||
StoragePointer(ctx, binding, offset, type_def, element_size, member_ptr, index_offset)};
|
StoragePointer(ctx, binding, offset, type_def, element_size, member_ptr, index_offset)};
|
||||||
return ctx.OpLoad(result_type, pointer);
|
return ctx.OpLoad(result_type, pointer);
|
||||||
@@ -57,7 +44,7 @@ Id LoadStorage32(EmitContext& ctx, const IR::Value& binding, const IR::Value& of
|
|||||||
|
|
||||||
void WriteStorage(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, Id value,
|
void WriteStorage(EmitContext& ctx, const IR::Value& binding, const IR::Value& offset, Id value,
|
||||||
const StorageTypeDefinition& type_def, size_t element_size,
|
const StorageTypeDefinition& type_def, size_t element_size,
|
||||||
Id StorageDefinitions::*member_ptr, u32 index_offset = 0) {
|
Id StorageDefinitions::* member_ptr, u32 index_offset = 0) {
|
||||||
const Id pointer{
|
const Id pointer{
|
||||||
StoragePointer(ctx, binding, offset, type_def, element_size, member_ptr, index_offset)};
|
StoragePointer(ctx, binding, offset, type_def, element_size, member_ptr, index_offset)};
|
||||||
ctx.OpStore(pointer, value);
|
ctx.OpStore(pointer, value);
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ void DefineConstBuffers(EmitContext& ctx, const Info& info, Id UniformDefinition
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DefineSsbos(EmitContext& ctx, StorageTypeDefinition& type_def,
|
void DefineSsbos(EmitContext& ctx, StorageTypeDefinition& type_def,
|
||||||
Id StorageDefinitions::*member_type, const Info& info, u32 binding, Id type,
|
Id StorageDefinitions::* member_type, const Info& info, u32 binding, Id type,
|
||||||
u32 stride) {
|
u32 stride) {
|
||||||
const Id array_type{ctx.TypeRuntimeArray(type)};
|
const Id array_type{ctx.TypeRuntimeArray(type)};
|
||||||
ctx.Decorate(array_type, spv::Decoration::ArrayStride, stride);
|
ctx.Decorate(array_type, spv::Decoration::ArrayStride, stride);
|
||||||
@@ -309,23 +309,27 @@ void DefineSsbos(EmitContext& ctx, StorageTypeDefinition& type_def,
|
|||||||
ctx.MemberDecorate(struct_type, 0, spv::Decoration::Offset, 0U);
|
ctx.MemberDecorate(struct_type, 0, spv::Decoration::Offset, 0U);
|
||||||
|
|
||||||
const Id struct_pointer{ctx.TypePointer(spv::StorageClass::StorageBuffer, struct_type)};
|
const Id struct_pointer{ctx.TypePointer(spv::StorageClass::StorageBuffer, struct_type)};
|
||||||
type_def.array = struct_pointer;
|
|
||||||
type_def.element = ctx.TypePointer(spv::StorageClass::StorageBuffer, type);
|
type_def.element = ctx.TypePointer(spv::StorageClass::StorageBuffer, type);
|
||||||
|
|
||||||
u32 index{};
|
u32 index{};
|
||||||
for (const StorageBufferDescriptor& desc : info.storage_buffers_descriptors) {
|
for (const StorageBufferDescriptor& desc : info.storage_buffers_descriptors) {
|
||||||
const Id id{ctx.AddGlobalVariable(struct_pointer, spv::StorageClass::StorageBuffer)};
|
const Id variable_type{[&] {
|
||||||
|
if (desc.count == 1) {
|
||||||
|
return struct_pointer;
|
||||||
|
}
|
||||||
|
const Id descriptor_array{ctx.TypeArray(struct_type, ctx.Const(desc.count))};
|
||||||
|
return ctx.TypePointer(spv::StorageClass::StorageBuffer, descriptor_array);
|
||||||
|
}()};
|
||||||
|
const Id id{ctx.AddGlobalVariable(variable_type, spv::StorageClass::StorageBuffer)};
|
||||||
ctx.Decorate(id, spv::Decoration::Binding, binding);
|
ctx.Decorate(id, spv::Decoration::Binding, binding);
|
||||||
ctx.Decorate(id, spv::Decoration::DescriptorSet, 0U);
|
ctx.Decorate(id, spv::Decoration::DescriptorSet, 0U);
|
||||||
ctx.Name(id, fmt::format("ssbo{}", index));
|
ctx.Name(id, fmt::format("ssbo{}", index));
|
||||||
if (ctx.profile.supported_spirv >= 0x00010400) {
|
if (ctx.profile.supported_spirv >= 0x00010400) {
|
||||||
ctx.interfaces.push_back(id);
|
ctx.interfaces.push_back(id);
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < desc.count; ++i) {
|
ctx.ssbos[index].*member_type = id;
|
||||||
ctx.ssbos[index + i].*member_type = id;
|
++index;
|
||||||
}
|
++binding;
|
||||||
index += desc.count;
|
|
||||||
binding += desc.count;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,8 +372,7 @@ Id CasFunction(EmitContext& ctx, Operation operation, Id value_type) {
|
|||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
Id CasLoop(EmitContext& ctx, Operation operation, Id array_pointer, Id element_pointer,
|
Id CasLoop(EmitContext& ctx, Operation operation, Id element_pointer, Id value_type, Id memory_type, spv::Scope scope) {
|
||||||
Id value_type, Id memory_type, spv::Scope scope) {
|
|
||||||
const bool is_shared{scope == spv::Scope::Workgroup};
|
const bool is_shared{scope == spv::Scope::Workgroup};
|
||||||
const bool is_struct{!is_shared || ctx.uses_explicit_workgroup_layout};
|
const bool is_struct{!is_shared || ctx.uses_explicit_workgroup_layout};
|
||||||
const Id cas_func{CasFunction(ctx, operation, value_type)};
|
const Id cas_func{CasFunction(ctx, operation, value_type)};
|
||||||
@@ -379,14 +382,12 @@ Id CasLoop(EmitContext& ctx, Operation operation, Id array_pointer, Id element_p
|
|||||||
const Id loop_header{ctx.OpLabel()};
|
const Id loop_header{ctx.OpLabel()};
|
||||||
const Id continue_block{ctx.OpLabel()};
|
const Id continue_block{ctx.OpLabel()};
|
||||||
const Id merge_block{ctx.OpLabel()};
|
const Id merge_block{ctx.OpLabel()};
|
||||||
const Id func_type{is_shared
|
const Id func_type{is_shared ? ctx.TypeFunction(value_type, ctx.U32[1], value_type)
|
||||||
? ctx.TypeFunction(value_type, ctx.U32[1], value_type)
|
: ctx.TypeFunction(value_type, element_pointer, value_type)};
|
||||||
: ctx.TypeFunction(value_type, ctx.U32[1], value_type, array_pointer)};
|
|
||||||
|
|
||||||
const Id func{ctx.OpFunction(value_type, spv::FunctionControlMask::MaskNone, func_type)};
|
const Id func{ctx.OpFunction(value_type, spv::FunctionControlMask::MaskNone, func_type)};
|
||||||
const Id index{ctx.OpFunctionParameter(ctx.U32[1])};
|
const Id address{ctx.OpFunctionParameter(is_shared ? ctx.U32[1] : element_pointer)};
|
||||||
const Id op_b{ctx.OpFunctionParameter(value_type)};
|
const Id op_b{ctx.OpFunctionParameter(value_type)};
|
||||||
const Id base{is_shared ? ctx.shared_memory_u32 : ctx.OpFunctionParameter(array_pointer)};
|
|
||||||
ctx.AddLabel();
|
ctx.AddLabel();
|
||||||
ctx.OpBranch(loop_header);
|
ctx.OpBranch(loop_header);
|
||||||
ctx.AddLabel(loop_header);
|
ctx.AddLabel(loop_header);
|
||||||
@@ -395,8 +396,13 @@ Id CasLoop(EmitContext& ctx, Operation operation, Id array_pointer, Id element_p
|
|||||||
ctx.OpBranch(continue_block);
|
ctx.OpBranch(continue_block);
|
||||||
|
|
||||||
ctx.AddLabel(continue_block);
|
ctx.AddLabel(continue_block);
|
||||||
const Id word_pointer{is_struct ? ctx.OpAccessChain(element_pointer, base, zero, index)
|
const Id word_pointer{[&] {
|
||||||
: ctx.OpAccessChain(element_pointer, base, index)};
|
if (!is_shared) {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
return is_struct ? ctx.OpAccessChain(element_pointer, ctx.shared_memory_u32, zero, address)
|
||||||
|
: ctx.OpAccessChain(element_pointer, ctx.shared_memory_u32, address);
|
||||||
|
}()};
|
||||||
if (value_type.value == ctx.F32[2].value) {
|
if (value_type.value == ctx.F32[2].value) {
|
||||||
const Id u32_value{ctx.OpLoad(ctx.U32[1], word_pointer)};
|
const Id u32_value{ctx.OpLoad(ctx.U32[1], word_pointer)};
|
||||||
const Id value{ctx.OpUnpackHalf2x16(ctx.F32[2], u32_value)};
|
const Id value{ctx.OpUnpackHalf2x16(ctx.F32[2], u32_value)};
|
||||||
@@ -480,6 +486,7 @@ EmitContext::EmitContext(const Profile& profile_, const RuntimeInfo& runtime_inf
|
|||||||
DefineSharedMemoryFunctions(program);
|
DefineSharedMemoryFunctions(program);
|
||||||
DefineConstantBuffers(program.info, uniform_binding);
|
DefineConstantBuffers(program.info, uniform_binding);
|
||||||
DefineConstantBufferIndirectFunctions(program.info);
|
DefineConstantBufferIndirectFunctions(program.info);
|
||||||
|
DefineStorageBufferMappings(program.info, storage_binding);
|
||||||
DefineStorageBuffers(program.info, storage_binding);
|
DefineStorageBuffers(program.info, storage_binding);
|
||||||
DefineTextureBuffers(program.info, texture_binding);
|
DefineTextureBuffers(program.info, texture_binding);
|
||||||
DefineImageBuffers(program.info, image_binding);
|
DefineImageBuffers(program.info, image_binding);
|
||||||
@@ -532,6 +539,36 @@ Id EmitContext::BitOffset16(const IR::Value& offset) {
|
|||||||
return OpBitwiseAnd(U32[1], OpShiftLeftLogical(U32[1], Def(offset), Const(3u)), Const(16u));
|
return OpBitwiseAnd(U32[1], OpShiftLeftLogical(U32[1], Def(offset), Const(3u)), Const(16u));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Id EmitContext::StoragePointer(u32 binding, Id byte_offset, const StorageTypeDefinition& type_def,
|
||||||
|
u32 element_size, Id StorageDefinitions::* member_ptr) {
|
||||||
|
const Id ssbo{ssbos[binding].*member_ptr};
|
||||||
|
const u32 segment_count{storage_buffer_mapping_counts[binding]};
|
||||||
|
if (segment_count <= 1) {
|
||||||
|
const Id index{
|
||||||
|
element_size == 1
|
||||||
|
? byte_offset
|
||||||
|
: OpShiftRightLogical(U32[1], byte_offset, Const(static_cast<u32>(std::countr_zero(element_size))))};
|
||||||
|
return OpAccessChain(type_def.element, ssbo, u32_zero_value, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Id mapped{OpFunctionCall(U32[2], storage_buffer_map_func,
|
||||||
|
Const(storage_buffer_mapping_bases[binding]),
|
||||||
|
Const(segment_count), byte_offset)};
|
||||||
|
const Id segment{OpCompositeExtract(U32[1], mapped, 0U)};
|
||||||
|
const Id local_offset{OpCompositeExtract(U32[1], mapped, 1U)};
|
||||||
|
const Id index{
|
||||||
|
element_size == 1
|
||||||
|
? local_offset
|
||||||
|
: OpShiftRightLogical(U32[1], local_offset, Const(static_cast<u32>(std::countr_zero(element_size))))};
|
||||||
|
Decorate(segment, spv::Decoration::NonUniform);
|
||||||
|
non_uniform_ids.insert(segment.value);
|
||||||
|
const Id pointer{OpAccessChain(type_def.element, ssbo, segment, u32_zero_value, index)};
|
||||||
|
Decorate(pointer, spv::Decoration::NonUniform);
|
||||||
|
non_uniform_ids.insert(pointer.value);
|
||||||
|
uses_nonuniform_storage_buffer = true;
|
||||||
|
return pointer;
|
||||||
|
}
|
||||||
|
|
||||||
void EmitContext::DefineCommonTypes(const Info& info) {
|
void EmitContext::DefineCommonTypes(const Info& info) {
|
||||||
void_id = TypeVoid();
|
void_id = TypeVoid();
|
||||||
|
|
||||||
@@ -696,12 +733,10 @@ void EmitContext::DefineSharedMemory(const IR::Program& program) {
|
|||||||
|
|
||||||
void EmitContext::DefineSharedMemoryFunctions(const IR::Program& program) {
|
void EmitContext::DefineSharedMemoryFunctions(const IR::Program& program) {
|
||||||
if (program.info.uses_shared_increment) {
|
if (program.info.uses_shared_increment) {
|
||||||
increment_cas_shared = CasLoop(*this, Operation::Increment, shared_memory_u32_type,
|
increment_cas_shared = CasLoop(*this, Operation::Increment, shared_u32, U32[1], U32[1], spv::Scope::Workgroup);
|
||||||
shared_u32, U32[1], U32[1], spv::Scope::Workgroup);
|
|
||||||
}
|
}
|
||||||
if (program.info.uses_shared_decrement) {
|
if (program.info.uses_shared_decrement) {
|
||||||
decrement_cas_shared = CasLoop(*this, Operation::Decrement, shared_memory_u32_type,
|
decrement_cas_shared = CasLoop(*this, Operation::Decrement, shared_u32, U32[1], U32[1], spv::Scope::Workgroup);
|
||||||
shared_u32, U32[1], U32[1], spv::Scope::Workgroup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -945,8 +980,7 @@ void EmitContext::DefineGlobalMemoryFunctions(const Info& info) {
|
|||||||
}
|
}
|
||||||
using DefPtr = Id StorageDefinitions::*;
|
using DefPtr = Id StorageDefinitions::*;
|
||||||
const Id zero{u32_zero_value};
|
const Id zero{u32_zero_value};
|
||||||
const auto define_body{[&](DefPtr ssbo_member, Id addr, Id element_pointer, u32 shift,
|
const auto define_body{[&](DefPtr ssbo_member, Id addr, const StorageTypeDefinition& type_def, u32 shift, auto&& callback) {
|
||||||
auto&& callback) {
|
|
||||||
AddLabel();
|
AddLabel();
|
||||||
const size_t num_buffers{info.storage_buffers_descriptors.size()};
|
const size_t num_buffers{info.storage_buffers_descriptors.size()};
|
||||||
for (size_t index = 0; index < num_buffers; ++index) {
|
for (size_t index = 0; index < num_buffers; ++index) {
|
||||||
@@ -973,30 +1007,28 @@ void EmitContext::DefineGlobalMemoryFunctions(const Info& info) {
|
|||||||
OpSelectionMerge(else_label, spv::SelectionControlMask::MaskNone);
|
OpSelectionMerge(else_label, spv::SelectionControlMask::MaskNone);
|
||||||
OpBranchConditional(cond, then_label, else_label);
|
OpBranchConditional(cond, then_label, else_label);
|
||||||
AddLabel(then_label);
|
AddLabel(then_label);
|
||||||
const Id ssbo_id{ssbos[index].*ssbo_member};
|
|
||||||
const Id ssbo_offset{OpUConvert(U32[1], OpISub(U64, addr, ssbo_addr))};
|
const Id ssbo_offset{OpUConvert(U32[1], OpISub(U64, addr, ssbo_addr))};
|
||||||
const Id ssbo_index{OpShiftRightLogical(U32[1], ssbo_offset, Const(shift))};
|
const Id ssbo_pointer{StoragePointer(static_cast<u32>(index), ssbo_offset, type_def, 1U << shift, ssbo_member)};
|
||||||
const Id ssbo_pointer{OpAccessChain(element_pointer, ssbo_id, zero, ssbo_index)};
|
|
||||||
callback(ssbo_pointer);
|
callback(ssbo_pointer);
|
||||||
AddLabel(else_label);
|
AddLabel(else_label);
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
const auto define_load{[&](DefPtr ssbo_member, Id element_pointer, Id type, u32 shift) {
|
const auto define_load{
|
||||||
const Id function_type{TypeFunction(type, U64)};
|
[&](DefPtr ssbo_member, const StorageTypeDefinition& type_def, Id type, u32 shift) {
|
||||||
const Id func_id{OpFunction(type, spv::FunctionControlMask::MaskNone, function_type)};
|
const Id function_type{TypeFunction(type, U64)};
|
||||||
const Id addr{OpFunctionParameter(U64)};
|
const Id func_id{OpFunction(type, spv::FunctionControlMask::MaskNone, function_type)};
|
||||||
define_body(ssbo_member, addr, element_pointer, shift,
|
const Id addr{OpFunctionParameter(U64)};
|
||||||
[&](Id ssbo_pointer) { OpReturnValue(OpLoad(type, ssbo_pointer)); });
|
define_body(ssbo_member, addr, type_def, shift, [&](Id ssbo_pointer) { OpReturnValue(OpLoad(type, ssbo_pointer)); });
|
||||||
OpReturnValue(ConstantNull(type));
|
OpReturnValue(ConstantNull(type));
|
||||||
OpFunctionEnd();
|
OpFunctionEnd();
|
||||||
return func_id;
|
return func_id;
|
||||||
}};
|
}};
|
||||||
const auto define_write{[&](DefPtr ssbo_member, Id element_pointer, Id type, u32 shift) {
|
const auto define_write{[&](DefPtr ssbo_member, const StorageTypeDefinition& type_def, Id type, u32 shift) {
|
||||||
const Id function_type{TypeFunction(void_id, U64, type)};
|
const Id function_type{TypeFunction(void_id, U64, type)};
|
||||||
const Id func_id{OpFunction(void_id, spv::FunctionControlMask::MaskNone, function_type)};
|
const Id func_id{OpFunction(void_id, spv::FunctionControlMask::MaskNone, function_type)};
|
||||||
const Id addr{OpFunctionParameter(U64)};
|
const Id addr{OpFunctionParameter(U64)};
|
||||||
const Id data{OpFunctionParameter(type)};
|
const Id data{OpFunctionParameter(type)};
|
||||||
define_body(ssbo_member, addr, element_pointer, shift, [&](Id ssbo_pointer) {
|
define_body(ssbo_member, addr, type_def, shift, [&](Id ssbo_pointer) {
|
||||||
OpStore(ssbo_pointer, data);
|
OpStore(ssbo_pointer, data);
|
||||||
OpReturn();
|
OpReturn();
|
||||||
});
|
});
|
||||||
@@ -1006,10 +1038,9 @@ void EmitContext::DefineGlobalMemoryFunctions(const Info& info) {
|
|||||||
}};
|
}};
|
||||||
const auto define{
|
const auto define{
|
||||||
[&](DefPtr ssbo_member, const StorageTypeDefinition& type_def, Id type, size_t size) {
|
[&](DefPtr ssbo_member, const StorageTypeDefinition& type_def, Id type, size_t size) {
|
||||||
const Id element_type{type_def.element};
|
|
||||||
const u32 shift{static_cast<u32>(std::countr_zero(size))};
|
const u32 shift{static_cast<u32>(std::countr_zero(size))};
|
||||||
const Id load_func{define_load(ssbo_member, element_type, type, shift)};
|
const Id load_func{define_load(ssbo_member, type_def, type, shift)};
|
||||||
const Id write_func{define_write(ssbo_member, element_type, type, shift)};
|
const Id write_func{define_write(ssbo_member, type_def, type, shift)};
|
||||||
return std::make_pair(load_func, write_func);
|
return std::make_pair(load_func, write_func);
|
||||||
}};
|
}};
|
||||||
std::tie(load_global_func_u32, write_global_func_u32) =
|
std::tie(load_global_func_u32, write_global_func_u32) =
|
||||||
@@ -1228,6 +1259,79 @@ void EmitContext::DefineConstantBufferIndirectFunctions(const Info& info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmitContext::DefineStorageBufferMappings(const Info& info, u32& binding) {
|
||||||
|
if (!UsesStorageBufferMappings(info)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ASSERT(profile.support_storage_buffer_array_nonuniform_indexing);
|
||||||
|
AddExtension("SPV_KHR_storage_buffer_storage_class");
|
||||||
|
|
||||||
|
const u32 num_entries{NumDescriptors(info.storage_buffers_descriptors)};
|
||||||
|
const Id array_type{TypeArray(U32[1], Const(num_entries))};
|
||||||
|
Decorate(array_type, spv::Decoration::ArrayStride, sizeof(u32));
|
||||||
|
const Id struct_type{TypeStruct(array_type)};
|
||||||
|
Decorate(struct_type, spv::Decoration::Block);
|
||||||
|
MemberName(struct_type, 0, "segment_sizes");
|
||||||
|
MemberDecorate(struct_type, 0, spv::Decoration::Offset, 0U);
|
||||||
|
const Id pointer_type{TypePointer(spv::StorageClass::StorageBuffer, struct_type)};
|
||||||
|
storage_buffer_mapping_u32 = TypePointer(spv::StorageClass::StorageBuffer, U32[1]);
|
||||||
|
storage_buffer_mapping = AddGlobalVariable(pointer_type, spv::StorageClass::StorageBuffer);
|
||||||
|
Decorate(storage_buffer_mapping, spv::Decoration::Binding, binding++);
|
||||||
|
Decorate(storage_buffer_mapping, spv::Decoration::DescriptorSet, 0U);
|
||||||
|
Name(storage_buffer_mapping, "storage_buffer_mapping");
|
||||||
|
//Starting with version 1.4... (https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html)
|
||||||
|
if (profile.supported_spirv >= 0x00010400) {
|
||||||
|
interfaces.push_back(storage_buffer_mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 mapping_base{};
|
||||||
|
for (u32 index = 0; index < info.storage_buffers_descriptors.size(); ++index) {
|
||||||
|
const StorageBufferDescriptor& desc = info.storage_buffers_descriptors[index];
|
||||||
|
storage_buffer_mapping_bases[index] = mapping_base;
|
||||||
|
storage_buffer_mapping_counts[index] = desc.count;
|
||||||
|
mapping_base += desc.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Id function_type{TypeFunction(U32[2], U32[1], U32[1], U32[1])};
|
||||||
|
storage_buffer_map_func = OpFunction(U32[2], spv::FunctionControlMask::MaskNone, function_type);
|
||||||
|
const Id base{OpFunctionParameter(U32[1])};
|
||||||
|
const Id count{OpFunctionParameter(U32[1])};
|
||||||
|
const Id byte_offset{OpFunctionParameter(U32[1])};
|
||||||
|
const Id index_pointer_type{TypePointer(spv::StorageClass::Function, U32[1])};
|
||||||
|
const Id loop_header{OpLabel()};
|
||||||
|
const Id continue_block{OpLabel()};
|
||||||
|
const Id merge_block{OpLabel()};
|
||||||
|
AddLabel();
|
||||||
|
const Id segment_var{AddLocalVariable(index_pointer_type, spv::StorageClass::Function)};
|
||||||
|
const Id offset_var{AddLocalVariable(index_pointer_type, spv::StorageClass::Function)};
|
||||||
|
OpStore(segment_var, u32_zero_value);
|
||||||
|
OpStore(offset_var, byte_offset);
|
||||||
|
OpBranch(loop_header);
|
||||||
|
|
||||||
|
AddLabel(loop_header);
|
||||||
|
const Id segment{OpLoad(U32[1], segment_var)};
|
||||||
|
const Id local_offset{OpLoad(U32[1], offset_var)};
|
||||||
|
const Id mapping_index{OpIAdd(U32[1], base, segment)};
|
||||||
|
const Id size_pointer{OpAccessChain(storage_buffer_mapping_u32, storage_buffer_mapping, u32_zero_value, mapping_index)};
|
||||||
|
const Id segment_size{OpLoad(U32[1], size_pointer)};
|
||||||
|
const Id fits{OpULessThan(U1, local_offset, segment_size)};
|
||||||
|
const Id last_segment{OpISub(U32[1], count, Const(1U))};
|
||||||
|
const Id is_last{OpIEqual(U1, segment, last_segment)};
|
||||||
|
const Id found{OpLogicalOr(U1, fits, is_last)};
|
||||||
|
OpLoopMerge(merge_block, continue_block, spv::LoopControlMask::MaskNone);
|
||||||
|
OpBranchConditional(found, merge_block, continue_block);
|
||||||
|
|
||||||
|
AddLabel(continue_block);
|
||||||
|
OpStore(offset_var, OpISub(U32[1], local_offset, segment_size));
|
||||||
|
OpStore(segment_var, OpIAdd(U32[1], segment, Const(1U)));
|
||||||
|
OpBranch(loop_header);
|
||||||
|
|
||||||
|
AddLabel(merge_block);
|
||||||
|
OpReturnValue(OpCompositeConstruct(U32[2], segment, local_offset));
|
||||||
|
OpFunctionEnd();
|
||||||
|
Name(storage_buffer_map_func, "map_storage_buffer");
|
||||||
|
}
|
||||||
|
|
||||||
void EmitContext::DefineStorageBuffers(const Info& info, u32& binding) {
|
void EmitContext::DefineStorageBuffers(const Info& info, u32& binding) {
|
||||||
if (info.storage_buffers_descriptors.empty()) {
|
if (info.storage_buffers_descriptors.empty()) {
|
||||||
return;
|
return;
|
||||||
@@ -1271,9 +1375,7 @@ void EmitContext::DefineStorageBuffers(const Info& info, u32& binding) {
|
|||||||
DefineSsbos(*this, storage_types.U32x4, &StorageDefinitions::U32x4, info, binding, U32[4],
|
DefineSsbos(*this, storage_types.U32x4, &StorageDefinitions::U32x4, info, binding, U32[4],
|
||||||
sizeof(u32[4]));
|
sizeof(u32[4]));
|
||||||
}
|
}
|
||||||
for (const StorageBufferDescriptor& desc : info.storage_buffers_descriptors) {
|
binding += static_cast<u32>(info.storage_buffers_descriptors.size());
|
||||||
binding += desc.count;
|
|
||||||
}
|
|
||||||
const bool needs_function{
|
const bool needs_function{
|
||||||
info.uses_global_increment || info.uses_global_decrement || info.uses_atomic_f32_add ||
|
info.uses_global_increment || info.uses_global_decrement || info.uses_atomic_f32_add ||
|
||||||
info.uses_atomic_f16x2_add || info.uses_atomic_f16x2_min || info.uses_atomic_f16x2_max ||
|
info.uses_atomic_f16x2_add || info.uses_atomic_f16x2_min || info.uses_atomic_f16x2_max ||
|
||||||
@@ -1282,40 +1384,31 @@ void EmitContext::DefineStorageBuffers(const Info& info, u32& binding) {
|
|||||||
AddCapability(spv::Capability::VariablePointersStorageBuffer);
|
AddCapability(spv::Capability::VariablePointersStorageBuffer);
|
||||||
}
|
}
|
||||||
if (info.uses_global_increment) {
|
if (info.uses_global_increment) {
|
||||||
increment_cas_ssbo = CasLoop(*this, Operation::Increment, storage_types.U32.array,
|
increment_cas_ssbo = CasLoop(*this, Operation::Increment, storage_types.U32.element, U32[1], U32[1], spv::Scope::Device);
|
||||||
storage_types.U32.element, U32[1], U32[1], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
if (info.uses_global_decrement) {
|
if (info.uses_global_decrement) {
|
||||||
decrement_cas_ssbo = CasLoop(*this, Operation::Decrement, storage_types.U32.array,
|
decrement_cas_ssbo = CasLoop(*this, Operation::Decrement, storage_types.U32.element, U32[1], U32[1], spv::Scope::Device);
|
||||||
storage_types.U32.element, U32[1], U32[1], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
if (info.uses_atomic_f32_add) {
|
if (info.uses_atomic_f32_add) {
|
||||||
f32_add_cas = CasLoop(*this, Operation::FPAdd, storage_types.U32.array,
|
f32_add_cas = CasLoop(*this, Operation::FPAdd, storage_types.U32.element, F32[1], U32[1], spv::Scope::Device);
|
||||||
storage_types.U32.element, F32[1], U32[1], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
if (info.uses_atomic_f16x2_add) {
|
if (info.uses_atomic_f16x2_add) {
|
||||||
f16x2_add_cas = CasLoop(*this, Operation::FPAdd, storage_types.U32.array,
|
f16x2_add_cas = CasLoop(*this, Operation::FPAdd, storage_types.U32.element, F16[2], F16[2], spv::Scope::Device);
|
||||||
storage_types.U32.element, F16[2], F16[2], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
if (info.uses_atomic_f16x2_min) {
|
if (info.uses_atomic_f16x2_min) {
|
||||||
f16x2_min_cas = CasLoop(*this, Operation::FPMin, storage_types.U32.array,
|
f16x2_min_cas = CasLoop(*this, Operation::FPMin, storage_types.U32.element, F16[2], F16[2], spv::Scope::Device);
|
||||||
storage_types.U32.element, F16[2], F16[2], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
if (info.uses_atomic_f16x2_max) {
|
if (info.uses_atomic_f16x2_max) {
|
||||||
f16x2_max_cas = CasLoop(*this, Operation::FPMax, storage_types.U32.array,
|
f16x2_max_cas = CasLoop(*this, Operation::FPMax, storage_types.U32.element, F16[2], F16[2], spv::Scope::Device);
|
||||||
storage_types.U32.element, F16[2], F16[2], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
if (info.uses_atomic_f32x2_add) {
|
if (info.uses_atomic_f32x2_add) {
|
||||||
f32x2_add_cas = CasLoop(*this, Operation::FPAdd, storage_types.U32.array,
|
f32x2_add_cas = CasLoop(*this, Operation::FPAdd, storage_types.U32.element, F32[2], F32[2], spv::Scope::Device);
|
||||||
storage_types.U32.element, F32[2], F32[2], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
if (info.uses_atomic_f32x2_min) {
|
if (info.uses_atomic_f32x2_min) {
|
||||||
f32x2_min_cas = CasLoop(*this, Operation::FPMin, storage_types.U32.array,
|
f32x2_min_cas = CasLoop(*this, Operation::FPMin, storage_types.U32.element, F32[2], F32[2], spv::Scope::Device);
|
||||||
storage_types.U32.element, F32[2], F32[2], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
if (info.uses_atomic_f32x2_max) {
|
if (info.uses_atomic_f32x2_max) {
|
||||||
f32x2_max_cas = CasLoop(*this, Operation::FPMax, storage_types.U32.array,
|
f32x2_max_cas = CasLoop(*this, Operation::FPMax, storage_types.U32.element, F32[2], F32[2], spv::Scope::Device);
|
||||||
storage_types.U32.element, F32[2], F32[2], spv::Scope::Device);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ struct UniformDefinitions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct StorageTypeDefinition {
|
struct StorageTypeDefinition {
|
||||||
Id array{};
|
|
||||||
Id element{};
|
Id element{};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -173,6 +172,8 @@ public:
|
|||||||
[[nodiscard]] Id BitOffset8(const IR::Value& offset);
|
[[nodiscard]] Id BitOffset8(const IR::Value& offset);
|
||||||
[[nodiscard]] Id BitOffset16(const IR::Value& offset);
|
[[nodiscard]] Id BitOffset16(const IR::Value& offset);
|
||||||
|
|
||||||
|
[[nodiscard]] Id StoragePointer(u32 binding, Id byte_offset, const StorageTypeDefinition& type_def, u32 element_size, Id StorageDefinitions::*member_ptr);
|
||||||
|
|
||||||
Id Const(u32 value) {
|
Id Const(u32 value) {
|
||||||
return Constant(U32[1], value);
|
return Constant(U32[1], value);
|
||||||
}
|
}
|
||||||
@@ -257,6 +258,11 @@ public:
|
|||||||
|
|
||||||
std::array<UniformDefinitions, Info::MAX_CBUFS> cbufs{};
|
std::array<UniformDefinitions, Info::MAX_CBUFS> cbufs{};
|
||||||
std::array<StorageDefinitions, Info::MAX_SSBOS> ssbos{};
|
std::array<StorageDefinitions, Info::MAX_SSBOS> ssbos{};
|
||||||
|
std::array<u32, Info::MAX_SSBOS> storage_buffer_mapping_bases{};
|
||||||
|
std::array<u32, Info::MAX_SSBOS> storage_buffer_mapping_counts{};
|
||||||
|
Id storage_buffer_mapping{};
|
||||||
|
Id storage_buffer_mapping_u32{};
|
||||||
|
Id storage_buffer_map_func{};
|
||||||
std::vector<TextureBufferDefinition> texture_buffers;
|
std::vector<TextureBufferDefinition> texture_buffers;
|
||||||
std::vector<ImageBufferDefinition> image_buffers;
|
std::vector<ImageBufferDefinition> image_buffers;
|
||||||
std::vector<TextureDefinition> textures;
|
std::vector<TextureDefinition> textures;
|
||||||
@@ -376,6 +382,7 @@ public:
|
|||||||
bool uses_nonuniform_storage_image{};
|
bool uses_nonuniform_storage_image{};
|
||||||
bool uses_nonuniform_uniform_texel_buffer{};
|
bool uses_nonuniform_uniform_texel_buffer{};
|
||||||
bool uses_nonuniform_storage_texel_buffer{};
|
bool uses_nonuniform_storage_texel_buffer{};
|
||||||
|
bool uses_nonuniform_storage_buffer{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DefineCommonTypes(const Info& info);
|
void DefineCommonTypes(const Info& info);
|
||||||
@@ -386,6 +393,7 @@ private:
|
|||||||
void DefineSharedMemoryFunctions(const IR::Program& program);
|
void DefineSharedMemoryFunctions(const IR::Program& program);
|
||||||
void DefineConstantBuffers(const Info& info, u32& binding);
|
void DefineConstantBuffers(const Info& info, u32& binding);
|
||||||
void DefineConstantBufferIndirectFunctions(const Info& info);
|
void DefineConstantBufferIndirectFunctions(const Info& info);
|
||||||
|
void DefineStorageBufferMappings(const Info& info, u32& binding);
|
||||||
void DefineStorageBuffers(const Info& info, u32& binding);
|
void DefineStorageBuffers(const Info& info, u32& binding);
|
||||||
void DefineTextureBuffers(const Info& info, u32& binding);
|
void DefineTextureBuffers(const Info& info, u32& binding);
|
||||||
void DefineImageBuffers(const Info& info, u32& binding);
|
void DefineImageBuffers(const Info& info, u32& binding);
|
||||||
|
|||||||
@@ -132,6 +132,14 @@ void AddNVNStorageBuffers(IR::Program& program) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigureStorageBufferMappings(IR::Program& program, const HostTranslateInfo& host_info) {
|
||||||
|
// https://docs.vulkan.org/guide/latest/descriptor_arrays.html
|
||||||
|
// will be needed: descriptor array elements represent physical spans of one guest virtual buffer.
|
||||||
|
for (StorageBufferDescriptor& desc : program.info.storage_buffers_descriptors) {
|
||||||
|
desc.count = host_info.storage_buffer_segment_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
using IR::IsLegacyAttribute; //rescoped to attribute.h to make it visible in load_store_attribute.cpp IPA
|
using IR::IsLegacyAttribute; //rescoped to attribute.h to make it visible in load_store_attribute.cpp IPA
|
||||||
|
|
||||||
std::map<IR::Attribute, IR::Attribute> GenerateLegacyToGenericMappings(
|
std::map<IR::Attribute, IR::Attribute> GenerateLegacyToGenericMappings(
|
||||||
@@ -299,6 +307,7 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo
|
|||||||
Optimization::PositionPass(env, program);
|
Optimization::PositionPass(env, program);
|
||||||
|
|
||||||
Optimization::GlobalMemoryToStorageBufferPass(program, normalized_host_info);
|
Optimization::GlobalMemoryToStorageBufferPass(program, normalized_host_info);
|
||||||
|
ConfigureStorageBufferMappings(program, normalized_host_info);
|
||||||
Optimization::TexturePass(env, program, normalized_host_info);
|
Optimization::TexturePass(env, program, normalized_host_info);
|
||||||
|
|
||||||
if (Settings::values.resolution_info.active || Settings::values.rescale_hack.GetValue()) {
|
if (Settings::values.resolution_info.active || Settings::values.rescale_hack.GetValue()) {
|
||||||
@@ -314,6 +323,7 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo
|
|||||||
|
|
||||||
CollectInterpolationInfo(env, program);
|
CollectInterpolationInfo(env, program);
|
||||||
AddNVNStorageBuffers(program);
|
AddNVNStorageBuffers(program);
|
||||||
|
ConfigureStorageBufferMappings(program, normalized_host_info);
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
namespace Shader {
|
namespace Shader {
|
||||||
@@ -19,6 +20,7 @@ struct HostTranslateInfo {
|
|||||||
|
|
||||||
u64 min_ssbo_alignment{}; ///< Minimum alignment supported by the device for SSBOs
|
u64 min_ssbo_alignment{}; ///< Minimum alignment supported by the device for SSBOs
|
||||||
u32 max_per_stage_descriptor_sampled_images{}; ///< maximum sampled descriptors per stage
|
u32 max_per_stage_descriptor_sampled_images{}; ///< maximum sampled descriptors per stage
|
||||||
|
u32 max_per_stage_descriptor_storage_buffers{}; ///< maximum storage descriptors per stage
|
||||||
u32 max_per_stage_resources{}; ///< maximum resources per stage
|
u32 max_per_stage_resources{}; ///< maximum resources per stage
|
||||||
u32 max_descriptor_set_samplers{};
|
u32 max_descriptor_set_samplers{};
|
||||||
u32 max_descriptor_set_uniform_buffers{};
|
u32 max_descriptor_set_uniform_buffers{};
|
||||||
@@ -38,12 +40,14 @@ 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
|
||||||
|
u32 storage_buffer_segment_count{1}; ///< Physical ranges available to each guest SSBO
|
||||||
|
|
||||||
void ApplyDescriptorLimitPolicy() noexcept {
|
void ApplyDescriptorLimitPolicy() noexcept {
|
||||||
if (min_ssbo_alignment == 0) {
|
if (min_ssbo_alignment == 0) {
|
||||||
min_ssbo_alignment = 1;
|
min_ssbo_alignment = 1;
|
||||||
}
|
}
|
||||||
ApplyDescriptorLimitFallback(max_per_stage_descriptor_sampled_images);
|
ApplyDescriptorLimitFallback(max_per_stage_descriptor_sampled_images);
|
||||||
|
ApplyDescriptorLimitFallback(max_per_stage_descriptor_storage_buffers);
|
||||||
ApplyDescriptorLimitFallback(max_per_stage_resources);
|
ApplyDescriptorLimitFallback(max_per_stage_resources);
|
||||||
ApplyDescriptorLimitFallback(max_descriptor_set_samplers);
|
ApplyDescriptorLimitFallback(max_descriptor_set_samplers);
|
||||||
ApplyDescriptorLimitFallback(max_descriptor_set_uniform_buffers);
|
ApplyDescriptorLimitFallback(max_descriptor_set_uniform_buffers);
|
||||||
@@ -53,6 +57,7 @@ struct HostTranslateInfo {
|
|||||||
ApplyDescriptorLimitFallback(max_descriptor_set_sampled_images);
|
ApplyDescriptorLimitFallback(max_descriptor_set_sampled_images);
|
||||||
ApplyDescriptorLimitFallback(max_descriptor_set_storage_images);
|
ApplyDescriptorLimitFallback(max_descriptor_set_storage_images);
|
||||||
ApplyDescriptorLimitFallback(max_descriptor_set_input_attachements);
|
ApplyDescriptorLimitFallback(max_descriptor_set_input_attachements);
|
||||||
|
storage_buffer_segment_count = (std::max)(storage_buffer_segment_count, 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ struct Profile {
|
|||||||
bool support_storage_image_array_nonuniform_indexing{};
|
bool support_storage_image_array_nonuniform_indexing{};
|
||||||
bool support_uniform_texel_buffer_array_nonuniform_indexing{};
|
bool support_uniform_texel_buffer_array_nonuniform_indexing{};
|
||||||
bool support_storage_texel_buffer_array_nonuniform_indexing{};
|
bool support_storage_texel_buffer_array_nonuniform_indexing{};
|
||||||
|
bool support_storage_buffer_array_nonuniform_indexing{};
|
||||||
|
|
||||||
bool warp_size_potentially_larger_than_guest{};
|
bool warp_size_potentially_larger_than_guest{};
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -340,6 +341,10 @@ struct Info {
|
|||||||
ImageDescriptors image_descriptors;
|
ImageDescriptors image_descriptors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] inline bool UsesStorageBufferMappings(const Info& info) noexcept {
|
||||||
|
return std::ranges::any_of(info.storage_buffers_descriptors, [](const auto& desc) { return desc.count > 1; });
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Descriptors>
|
template <typename Descriptors>
|
||||||
u32 NumDescriptors(const Descriptors& descriptors) {
|
u32 NumDescriptors(const Descriptors& descriptors) {
|
||||||
u32 num{};
|
u32 num{};
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ namespace VideoCommon {
|
|||||||
|
|
||||||
enum class BufferFlagBits {
|
enum class BufferFlagBits {
|
||||||
Picked = 1 << 0,
|
Picked = 1 << 0,
|
||||||
|
CachedWrites = 1 << 1,
|
||||||
|
PreemtiveDownload = 1 << 2,
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_FLAG_OPERATORS(BufferFlagBits)
|
DECLARE_ENUM_FLAG_OPERATORS(BufferFlagBits)
|
||||||
|
|
||||||
@@ -56,6 +58,15 @@ public:
|
|||||||
flags |= BufferFlagBits::Picked;
|
flags |= BufferFlagBits::Picked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MarkPreemtiveDownload() noexcept {
|
||||||
|
flags |= BufferFlagBits::PreemtiveDownload;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Unmark buffer as picked
|
||||||
|
void Unpick() noexcept {
|
||||||
|
flags &= ~BufferFlagBits::Picked;
|
||||||
|
}
|
||||||
|
|
||||||
/// Increases the likeliness of this being a stream buffer
|
/// Increases the likeliness of this being a stream buffer
|
||||||
void IncreaseStreamScore(int score) noexcept {
|
void IncreaseStreamScore(int score) noexcept {
|
||||||
stream_score += score;
|
stream_score += score;
|
||||||
@@ -76,6 +87,15 @@ public:
|
|||||||
return True(flags & BufferFlagBits::Picked);
|
return True(flags & BufferFlagBits::Picked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true when the buffer has pending cached writes
|
||||||
|
[[nodiscard]] bool HasCachedWrites() const noexcept {
|
||||||
|
return True(flags & BufferFlagBits::CachedWrites);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsPreemtiveDownload() const noexcept {
|
||||||
|
return True(flags & BufferFlagBits::PreemtiveDownload);
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the base CPU address of the buffer
|
/// Returns the base CPU address of the buffer
|
||||||
[[nodiscard]] VAddr CpuAddr() const noexcept {
|
[[nodiscard]] VAddr CpuAddr() const noexcept {
|
||||||
return cpu_addr;
|
return cpu_addr;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
@@ -122,6 +123,25 @@ void BufferCache<P>::WriteMemory(DAddr device_addr, u64 size) {
|
|||||||
memory_tracker.MarkRegionAsCpuModified(device_addr, size);
|
memory_tracker.MarkRegionAsCpuModified(device_addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class P>
|
||||||
|
void BufferCache<P>::CachedWriteMemory(DAddr device_addr, u64 size) {
|
||||||
|
const bool is_dirty = IsRegionRegistered(device_addr, size);
|
||||||
|
if (!is_dirty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DAddr aligned_start = Common::AlignDown(device_addr, DEVICE_PAGESIZE);
|
||||||
|
DAddr aligned_end = Common::AlignUp(device_addr + size, DEVICE_PAGESIZE);
|
||||||
|
if (!IsRegionGpuModified(aligned_start, aligned_end - aligned_start)) {
|
||||||
|
WriteMemory(device_addr, size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp_buffer.resize_destructive(size);
|
||||||
|
device_memory.ReadBlockUnsafe(device_addr, tmp_buffer.data(), size);
|
||||||
|
|
||||||
|
InlineMemoryImplementation(device_addr, size, tmp_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
bool BufferCache<P>::OnCPUWrite(DAddr device_addr, u64 size) {
|
bool BufferCache<P>::OnCPUWrite(DAddr device_addr, u64 size) {
|
||||||
const bool is_dirty = IsRegionRegistered(device_addr, size);
|
const bool is_dirty = IsRegionRegistered(device_addr, size);
|
||||||
@@ -404,8 +424,8 @@ void BufferCache<P>::UnbindGraphicsStorageBuffers(size_t stage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, u32 cbuf_index,
|
bool BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, u32 cbuf_index,
|
||||||
u32 cbuf_offset, bool is_written) {
|
u32 cbuf_offset, bool is_written, u32 descriptor_count) {
|
||||||
const bool already_enabled =
|
const bool already_enabled =
|
||||||
((channel_state->enabled_storage_buffers[stage] >> ssbo_index) & 1U) != 0;
|
((channel_state->enabled_storage_buffers[stage] >> ssbo_index) & 1U) != 0;
|
||||||
if constexpr (requires { runtime.ShouldLimitDynamicStorageBuffers(); }) {
|
if constexpr (requires { runtime.ShouldLimitDynamicStorageBuffers(); }) {
|
||||||
@@ -415,7 +435,7 @@ void BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index,
|
|||||||
LOG_WARNING(HW_GPU,
|
LOG_WARNING(HW_GPU,
|
||||||
"Skipping graphics storage buffer {} due to driver limit {}",
|
"Skipping graphics storage buffer {} due to driver limit {}",
|
||||||
ssbo_index, max_bindings);
|
ssbo_index, max_bindings);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -430,7 +450,8 @@ void BufferCache<P>::BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index,
|
|||||||
const auto& cbufs = maxwell3d->state.shader_stages[stage];
|
const auto& cbufs = maxwell3d->state.shader_stages[stage];
|
||||||
const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset;
|
const GPUVAddr ssbo_addr = cbufs.const_buffers[cbuf_index].address + cbuf_offset;
|
||||||
channel_state->storage_buffers[stage][ssbo_index] =
|
channel_state->storage_buffers[stage][ssbo_index] =
|
||||||
StorageBufferBinding(ssbo_addr, cbuf_index, is_written);
|
StorageBufferBinding(ssbo_addr, cbuf_index, is_written, descriptor_count);
|
||||||
|
return channel_state->storage_buffers[stage][ssbo_index].gpu_addr != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
@@ -468,7 +489,7 @@ void BufferCache<P>::UnbindComputeStorageBuffers() {
|
|||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index, u32 cbuf_offset,
|
void BufferCache<P>::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index, u32 cbuf_offset,
|
||||||
bool is_written) {
|
bool is_written, u32 descriptor_count) {
|
||||||
if (ssbo_index >= channel_state->compute_storage_buffers.size()) [[unlikely]] {
|
if (ssbo_index >= channel_state->compute_storage_buffers.size()) [[unlikely]] {
|
||||||
LOG_ERROR(HW_GPU, "Storage buffer index {} exceeds maximum storage buffer count",
|
LOG_ERROR(HW_GPU, "Storage buffer index {} exceeds maximum storage buffer count",
|
||||||
ssbo_index);
|
ssbo_index);
|
||||||
@@ -505,7 +526,7 @@ void BufferCache<P>::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index,
|
|||||||
const auto& cbufs = launch_desc.const_buffer_config;
|
const auto& cbufs = launch_desc.const_buffer_config;
|
||||||
const GPUVAddr ssbo_addr = cbufs[cbuf_index].Address() + cbuf_offset;
|
const GPUVAddr ssbo_addr = cbufs[cbuf_index].Address() + cbuf_offset;
|
||||||
channel_state->compute_storage_buffers[ssbo_index] =
|
channel_state->compute_storage_buffers[ssbo_index] =
|
||||||
StorageBufferBinding(ssbo_addr, cbuf_index, is_written);
|
StorageBufferBinding(ssbo_addr, cbuf_index, is_written, descriptor_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
@@ -743,6 +764,16 @@ void BufferCache<P>::BindHostIndexBuffer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class P>
|
||||||
|
void BufferCache<P>::BindHostVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size,
|
||||||
|
u32 stride) {
|
||||||
|
if constexpr (IS_OPENGL) {
|
||||||
|
runtime.BindVertexBuffer(index, buffer, offset, size, stride);
|
||||||
|
} else {
|
||||||
|
runtime.BindVertexBuffer(index, buffer.Handle(), offset, size, stride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
Binding& BufferCache<P>::VertexBufferSlot(u32 index) {
|
Binding& BufferCache<P>::VertexBufferSlot(u32 index) {
|
||||||
ASSERT(index < NUM_VERTEX_BUFFERS);
|
ASSERT(index < NUM_VERTEX_BUFFERS);
|
||||||
@@ -971,27 +1002,52 @@ void BufferCache<P>::BindHostGraphicsUniformBuffer(size_t stage, u32 index, u32
|
|||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::BindHostGraphicsStorageBuffers(size_t stage) {
|
void BufferCache<P>::BindHostGraphicsStorageBuffers(size_t stage) {
|
||||||
|
boost::container::small_vector<u32, NUM_STORAGE_BUFFERS> segment_sizes;
|
||||||
|
bool uses_mapping{};
|
||||||
|
ForEachEnabledBit(channel_state->enabled_storage_buffers[stage], [&](u32 index) {
|
||||||
|
const StorageBufferBindingInfo& binding = channel_state->storage_buffers[stage][index];
|
||||||
|
uses_mapping |= binding.descriptor_count > 1;
|
||||||
|
for (u32 segment = 0; segment < binding.descriptor_count; ++segment) {
|
||||||
|
segment_sizes.push_back(segment < binding.segments.size() ? binding.segments[segment].size : 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (uses_mapping) {
|
||||||
|
const u32 mapping_size = static_cast<u32>(segment_sizes.size() * sizeof(u32));
|
||||||
|
if constexpr (!IS_OPENGL) {
|
||||||
|
const std::span<u8> mapped = runtime.BindMappedStorageBuffer(mapping_size);
|
||||||
|
std::memcpy(mapped.data(), segment_sizes.data(), mapping_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u32 binding_index = 0;
|
u32 binding_index = 0;
|
||||||
ForEachEnabledBit(channel_state->enabled_storage_buffers[stage], [&](u32 index) {
|
ForEachEnabledBit(channel_state->enabled_storage_buffers[stage], [&](u32 index) {
|
||||||
const Binding& binding = channel_state->storage_buffers[stage][index];
|
const StorageBufferBindingInfo& storage = channel_state->storage_buffers[stage][index];
|
||||||
Buffer& buffer = slot_buffers[binding.buffer_id];
|
|
||||||
TouchBuffer(buffer, binding.buffer_id);
|
|
||||||
const u32 size = binding.size;
|
|
||||||
SynchronizeBuffer(buffer, binding.device_addr, size);
|
|
||||||
|
|
||||||
const u32 offset = buffer.Offset(binding.device_addr);
|
|
||||||
buffer.MarkUsage(offset, size);
|
|
||||||
const bool is_written = ((channel_state->written_storage_buffers[stage] >> index) & 1) != 0;
|
const bool is_written = ((channel_state->written_storage_buffers[stage] >> index) & 1) != 0;
|
||||||
|
for (u32 segment = 0; segment < storage.descriptor_count; ++segment) {
|
||||||
if (is_written) {
|
Buffer* buffer = &slot_buffers[NULL_BUFFER_ID];
|
||||||
MarkWrittenBuffer(binding.buffer_id, binding.device_addr, size);
|
u32 offset{};
|
||||||
}
|
u32 size{IS_OPENGL ? 0U : static_cast<u32>(sizeof(u32))};
|
||||||
|
const bool is_actual_segment = segment < storage.segments.size();
|
||||||
if constexpr (NEEDS_BIND_STORAGE_INDEX) {
|
// shall be safe enough if the segment is not actual, use the last available segment or nullptr if none exist.
|
||||||
runtime.BindStorageBuffer(stage, binding_index, buffer, offset, size, is_written);
|
const Binding* binding = is_actual_segment ? &storage.segments[segment] : storage.segments.empty() ? nullptr : &storage.segments.back();
|
||||||
++binding_index;
|
if (binding) {
|
||||||
} else {
|
buffer = &slot_buffers[binding->buffer_id];
|
||||||
runtime.BindStorageBuffer(buffer, offset, size, is_written);
|
size = binding->size;
|
||||||
|
offset = buffer->Offset(binding->device_addr);
|
||||||
|
if (is_actual_segment) {
|
||||||
|
TouchBuffer(*buffer, binding->buffer_id);
|
||||||
|
SynchronizeBuffer(*buffer, binding->device_addr, size);
|
||||||
|
buffer->MarkUsage(offset, size);
|
||||||
|
if (is_written) {
|
||||||
|
MarkWrittenBuffer(binding->buffer_id, binding->device_addr, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if constexpr (NEEDS_BIND_STORAGE_INDEX) {
|
||||||
|
runtime.BindStorageBuffer(stage, binding_index++, *buffer, offset, size, is_written);
|
||||||
|
} else {
|
||||||
|
runtime.BindStorageBuffer(*buffer, offset, size, is_written);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1107,28 +1163,53 @@ void BufferCache<P>::BindHostComputeUniformBuffers() {
|
|||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::BindHostComputeStorageBuffers() {
|
void BufferCache<P>::BindHostComputeStorageBuffers() {
|
||||||
|
boost::container::small_vector<u32, NUM_STORAGE_BUFFERS> segment_sizes;
|
||||||
|
bool uses_mapping{};
|
||||||
|
ForEachEnabledBit(channel_state->enabled_compute_storage_buffers, [&](u32 index) {
|
||||||
|
const StorageBufferBindingInfo& binding = channel_state->compute_storage_buffers[index];
|
||||||
|
uses_mapping |= binding.descriptor_count > 1;
|
||||||
|
for (u32 segment = 0; segment < binding.descriptor_count; ++segment) {
|
||||||
|
segment_sizes.push_back(segment < binding.segments.size() ? binding.segments[segment].size : 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (uses_mapping) {
|
||||||
|
const u32 mapping_size = static_cast<u32>(segment_sizes.size() * sizeof(u32));
|
||||||
|
if constexpr (!IS_OPENGL) {
|
||||||
|
const std::span<u8> mapped = runtime.BindMappedStorageBuffer(mapping_size);
|
||||||
|
std::memcpy(mapped.data(), segment_sizes.data(), mapping_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u32 binding_index = 0;
|
u32 binding_index = 0;
|
||||||
ForEachEnabledBit(channel_state->enabled_compute_storage_buffers, [&](u32 index) {
|
ForEachEnabledBit(channel_state->enabled_compute_storage_buffers, [&](u32 index) {
|
||||||
const Binding& binding = channel_state->compute_storage_buffers[index];
|
const StorageBufferBindingInfo& storage = channel_state->compute_storage_buffers[index];
|
||||||
Buffer& buffer = slot_buffers[binding.buffer_id];
|
|
||||||
TouchBuffer(buffer, binding.buffer_id);
|
|
||||||
const u32 size = binding.size;
|
|
||||||
SynchronizeBuffer(buffer, binding.device_addr, size);
|
|
||||||
|
|
||||||
const u32 offset = buffer.Offset(binding.device_addr);
|
|
||||||
buffer.MarkUsage(offset, size);
|
|
||||||
const bool is_written =
|
const bool is_written =
|
||||||
((channel_state->written_compute_storage_buffers >> index) & 1) != 0;
|
((channel_state->written_compute_storage_buffers >> index) & 1) != 0;
|
||||||
|
for (u32 segment = 0; segment < storage.descriptor_count; ++segment) {
|
||||||
if (is_written) {
|
Buffer* buffer = &slot_buffers[NULL_BUFFER_ID];
|
||||||
MarkWrittenBuffer(binding.buffer_id, binding.device_addr, size);
|
u32 offset{};
|
||||||
}
|
u32 size{IS_OPENGL ? 0U : static_cast<u32>(sizeof(u32))};
|
||||||
|
const bool is_actual_segment = segment < storage.segments.size();
|
||||||
if constexpr (NEEDS_BIND_STORAGE_INDEX) {
|
//same fallback logic
|
||||||
runtime.BindComputeStorageBuffer(binding_index, buffer, offset, size, is_written);
|
const Binding* binding = is_actual_segment ? &storage.segments[segment] : storage.segments.empty() ? nullptr : &storage.segments.back();
|
||||||
++binding_index;
|
if (binding) {
|
||||||
} else {
|
buffer = &slot_buffers[binding->buffer_id];
|
||||||
runtime.BindStorageBuffer(buffer, offset, size, is_written);
|
size = binding->size;
|
||||||
|
offset = buffer->Offset(binding->device_addr);
|
||||||
|
if (is_actual_segment) {
|
||||||
|
TouchBuffer(*buffer, binding->buffer_id);
|
||||||
|
SynchronizeBuffer(*buffer, binding->device_addr, size);
|
||||||
|
buffer->MarkUsage(offset, size);
|
||||||
|
if (is_written) {
|
||||||
|
MarkWrittenBuffer(binding->buffer_id, binding->device_addr, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if constexpr (NEEDS_BIND_STORAGE_INDEX) {
|
||||||
|
runtime.BindComputeStorageBuffer(binding_index++, *buffer, offset, size, is_written);
|
||||||
|
} else {
|
||||||
|
runtime.BindStorageBuffer(*buffer, offset, size, is_written);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1168,7 +1249,7 @@ void BufferCache<P>::DoUpdateGraphicsBuffers(bool is_indexed) {
|
|||||||
if (is_indexed) {
|
if (is_indexed) {
|
||||||
UpdateIndexBuffer();
|
UpdateIndexBuffer();
|
||||||
}
|
}
|
||||||
UpdateVertexBuffers(is_indexed);
|
UpdateVertexBuffers();
|
||||||
UpdateTransformFeedbackBuffers();
|
UpdateTransformFeedbackBuffers();
|
||||||
for (size_t stage = 0; stage < NUM_STAGES; ++stage) {
|
for (size_t stage = 0; stage < NUM_STAGES; ++stage) {
|
||||||
UpdateUniformBuffers(stage);
|
UpdateUniformBuffers(stage);
|
||||||
@@ -1222,14 +1303,9 @@ void BufferCache<P>::UpdateIndexBuffer() {
|
|||||||
const GPUVAddr gpu_addr_begin = index_buffer_ref.StartAddress();
|
const GPUVAddr gpu_addr_begin = index_buffer_ref.StartAddress();
|
||||||
const GPUVAddr gpu_addr_end = index_buffer_ref.EndAddress();
|
const GPUVAddr gpu_addr_end = index_buffer_ref.EndAddress();
|
||||||
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
|
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
|
||||||
u64 address_size = 0;
|
const u32 address_size = static_cast<u32>(gpu_addr_end - gpu_addr_begin);
|
||||||
if (gpu_addr_end > gpu_addr_begin) {
|
const u32 draw_size = (index_buffer_ref.count + index_buffer_ref.first) * u32(index_buffer_ref.FormatSizeInBytes());
|
||||||
address_size = (std::min)(gpu_addr_end - gpu_addr_begin,
|
const u32 size = (std::min)(address_size, draw_size);
|
||||||
u64{(std::numeric_limits<u32>::max)()});
|
|
||||||
}
|
|
||||||
const u64 draw_size = (u64{index_buffer_ref.count} + u64{index_buffer_ref.first}) *
|
|
||||||
u64{index_buffer_ref.FormatSizeInBytes()};
|
|
||||||
const u32 size = static_cast<u32>((std::min)(address_size, draw_size));
|
|
||||||
if (size == 0 || !device_addr) {
|
if (size == 0 || !device_addr) {
|
||||||
channel_state->index_buffer = NULL_BINDING;
|
channel_state->index_buffer = NULL_BINDING;
|
||||||
return;
|
return;
|
||||||
@@ -1242,142 +1318,20 @@ void BufferCache<P>::UpdateIndexBuffer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
u64 BufferCache<P>::DrawMaxIndex() {
|
void BufferCache<P>::UpdateVertexBuffers() {
|
||||||
if (max_index_scanned) {
|
|
||||||
return cached_max_index;
|
|
||||||
}
|
|
||||||
max_index_scanned = true;
|
|
||||||
cached_max_index = 0;
|
|
||||||
const auto& index_buffer_ref = maxwell3d->draw_manager.draw_state.index_buffer;
|
|
||||||
const u32 count = index_buffer_ref.count;
|
|
||||||
if (count == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
index_scan_buffer.resize_destructive(count);
|
|
||||||
gpu_memory->ReadBlockUnsafe(index_buffer_ref.IndexStart(), index_scan_buffer.data(),
|
|
||||||
size_t{count} * sizeof(u32));
|
|
||||||
u32 restart_index = (std::numeric_limits<u32>::max)();
|
|
||||||
if (maxwell3d->regs.primitive_restart.enabled != 0) {
|
|
||||||
restart_index = maxwell3d->regs.primitive_restart.index;
|
|
||||||
}
|
|
||||||
u32 max_index = 0;
|
|
||||||
for (u32 i = 0; i < count; ++i) {
|
|
||||||
const u32 value = index_scan_buffer[i];
|
|
||||||
if (value == restart_index) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
max_index = (std::max)(max_index, value);
|
|
||||||
}
|
|
||||||
cached_max_index = max_index;
|
|
||||||
return cached_max_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class P>
|
|
||||||
u64 BufferCache<P>::StreamAttributeExtent(u32 index) {
|
|
||||||
using VertexAttribute = typename Maxwell::VertexAttribute;
|
|
||||||
if (stream_extents_valid) {
|
|
||||||
return stream_extents[index];
|
|
||||||
}
|
|
||||||
stream_extents_valid = true;
|
|
||||||
stream_extents.fill(0);
|
|
||||||
for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) {
|
|
||||||
const auto& attribute = maxwell3d->regs.vertex_attrib_format[i];
|
|
||||||
if (attribute.constant != 0 || attribute.size == VertexAttribute::Size::Invalid) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const u32 buffer = attribute.buffer.Value();
|
|
||||||
if (buffer >= NUM_VERTEX_BUFFERS) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const u64 end = static_cast<u64>(attribute.offset.Value()) +
|
|
||||||
static_cast<u64>(attribute.SizeInBytes());
|
|
||||||
stream_extents[buffer] = (std::max)(stream_extents[buffer], end);
|
|
||||||
}
|
|
||||||
return stream_extents[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class P>
|
|
||||||
u64 BufferCache<P>::DrawVertexBound(u32 index, bool is_indexed) {
|
|
||||||
const auto& array = maxwell3d->regs.vertex_streams[index];
|
|
||||||
if (array.enable == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
const u64 extent = StreamAttributeExtent(index);
|
|
||||||
if (extent == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
const u64 stride = static_cast<u64>(array.stride);
|
|
||||||
if (stride == 0) {
|
|
||||||
return extent;
|
|
||||||
}
|
|
||||||
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
|
||||||
u64 elements = 0;
|
|
||||||
if (maxwell3d->regs.vertex_stream_instances.IsInstancingEnabled(index)) {
|
|
||||||
if (draw_instance_count == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
const u64 base_instance = static_cast<u64>(draw_state.base_instance);
|
|
||||||
elements = base_instance + 1;
|
|
||||||
if (array.frequency != 0) {
|
|
||||||
elements = (base_instance + static_cast<u64>(draw_instance_count) - 1) /
|
|
||||||
static_cast<u64>(array.frequency) +
|
|
||||||
1;
|
|
||||||
}
|
|
||||||
} else if (!is_indexed) {
|
|
||||||
elements = static_cast<u64>(draw_state.vertex_buffer.first) +
|
|
||||||
static_cast<u64>(draw_state.vertex_buffer.count);
|
|
||||||
} else {
|
|
||||||
const auto format = draw_state.index_buffer.format;
|
|
||||||
u64 max_index = 0xFF;
|
|
||||||
if (format == Maxwell::IndexFormat::UnsignedShort) {
|
|
||||||
max_index = 0xFFFF;
|
|
||||||
} else if (format != Maxwell::IndexFormat::UnsignedByte) {
|
|
||||||
const auto& limit = maxwell3d->regs.vertex_stream_limits[index];
|
|
||||||
const GPUVAddr gpu_addr_begin = array.Address();
|
|
||||||
const GPUVAddr gpu_addr_end = limit.Address() + 1;
|
|
||||||
if (gpu_addr_end <= gpu_addr_begin) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
const bool walks = gpu_addr_end - gpu_addr_begin >= IMPLAUSIBLE_VERTEX_SIZE ||
|
|
||||||
!gpu_memory->IsWithinGPUAddressRange(gpu_addr_end);
|
|
||||||
if (!walks) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
max_index = DrawMaxIndex();
|
|
||||||
}
|
|
||||||
elements = static_cast<u64>(draw_state.base_index) + max_index + 1;
|
|
||||||
}
|
|
||||||
if (elements == 0) {
|
|
||||||
return extent;
|
|
||||||
}
|
|
||||||
return (elements - 1) * stride + extent;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class P>
|
|
||||||
void BufferCache<P>::UpdateVertexBuffers(bool is_indexed) {
|
|
||||||
auto& flags = maxwell3d->dirty.flags;
|
auto& flags = maxwell3d->dirty.flags;
|
||||||
max_index_scanned = false;
|
|
||||||
stream_extents_valid = false;
|
|
||||||
for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) {
|
|
||||||
const u64 bound = DrawVertexBound(index, is_indexed);
|
|
||||||
if (bound <= last_draw_bounds[index]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
flags[Dirty::VertexBuffer0 + index] = true;
|
|
||||||
flags[Dirty::VertexBuffers] = true;
|
|
||||||
}
|
|
||||||
if (!maxwell3d->dirty.flags[Dirty::VertexBuffers]) {
|
if (!maxwell3d->dirty.flags[Dirty::VertexBuffers]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
flags[Dirty::VertexBuffers] = false;
|
flags[Dirty::VertexBuffers] = false;
|
||||||
|
|
||||||
for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) {
|
for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) {
|
||||||
UpdateVertexBuffer(index, is_indexed);
|
UpdateVertexBuffer(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::UpdateVertexBuffer(u32 index, bool is_indexed) {
|
void BufferCache<P>::UpdateVertexBuffer(u32 index) {
|
||||||
if (!maxwell3d->dirty.flags[Dirty::VertexBuffer0 + index]) {
|
if (!maxwell3d->dirty.flags[Dirty::VertexBuffer0 + index]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1386,31 +1340,15 @@ void BufferCache<P>::UpdateVertexBuffer(u32 index, bool is_indexed) {
|
|||||||
const GPUVAddr gpu_addr_begin = array.Address();
|
const GPUVAddr gpu_addr_begin = array.Address();
|
||||||
const GPUVAddr gpu_addr_end = limit.Address() + 1;
|
const GPUVAddr gpu_addr_end = limit.Address() + 1;
|
||||||
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
|
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
|
||||||
if (array.enable == 0 || !device_addr || gpu_addr_end <= gpu_addr_begin) {
|
const u32 address_size = static_cast<u32>(gpu_addr_end - gpu_addr_begin);
|
||||||
|
u32 size = address_size; // TODO: Analyze stride and number of vertices
|
||||||
|
if (array.enable == 0 || size == 0 || !device_addr) {
|
||||||
channel_state->vertex_buffers[index] = NULL_BINDING;
|
channel_state->vertex_buffers[index] = NULL_BINDING;
|
||||||
UpdateVertexBufferSlot(index, NULL_BINDING);
|
UpdateVertexBufferSlot(index, NULL_BINDING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: Analyze stride and number of vertices
|
if (!gpu_memory->IsWithinGPUAddressRange(gpu_addr_end) || size >= 64_MiB) {
|
||||||
constexpr u64 implausible_size = IMPLAUSIBLE_VERTEX_SIZE;
|
size = static_cast<u32>(gpu_memory->MaxContinuousRange(gpu_addr_begin, size));
|
||||||
u64 address_size = gpu_addr_end - gpu_addr_begin;
|
|
||||||
if (address_size > u64{(std::numeric_limits<u32>::max)()}) {
|
|
||||||
address_size = implausible_size;
|
|
||||||
}
|
|
||||||
const u64 draw_bound = DrawVertexBound(index, is_indexed);
|
|
||||||
last_draw_bounds[index] = (std::numeric_limits<u64>::max)();
|
|
||||||
if (draw_bound != 0) {
|
|
||||||
last_draw_bounds[index] = draw_bound;
|
|
||||||
address_size = (std::min)(address_size, draw_bound);
|
|
||||||
}
|
|
||||||
if (!gpu_memory->IsWithinGPUAddressRange(gpu_addr_end) || address_size >= implausible_size) {
|
|
||||||
address_size = gpu_memory->MaxContinuousRange(gpu_addr_begin, address_size);
|
|
||||||
}
|
|
||||||
const u32 size = static_cast<u32>(address_size);
|
|
||||||
if (size == 0) {
|
|
||||||
channel_state->vertex_buffers[index] = NULL_BINDING;
|
|
||||||
UpdateVertexBufferSlot(index, NULL_BINDING);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const BufferId buffer_id = FindBuffer(*device_addr, size);
|
const BufferId buffer_id = FindBuffer(*device_addr, size);
|
||||||
const Binding binding{
|
const Binding binding{
|
||||||
@@ -1464,10 +1402,7 @@ void BufferCache<P>::UpdateUniformBuffers(size_t stage) {
|
|||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::UpdateStorageBuffers(size_t stage) {
|
void BufferCache<P>::UpdateStorageBuffers(size_t stage) {
|
||||||
ForEachEnabledBit(channel_state->enabled_storage_buffers[stage], [&](u32 index) {
|
ForEachEnabledBit(channel_state->enabled_storage_buffers[stage], [&](u32 index) {
|
||||||
// Resolve buffer
|
UpdateStorageBuffer(channel_state->storage_buffers[stage][index]);
|
||||||
Binding& binding = channel_state->storage_buffers[stage][index];
|
|
||||||
const BufferId buffer_id = FindBuffer(binding.device_addr, binding.size);
|
|
||||||
binding.buffer_id = buffer_id;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1528,12 +1463,54 @@ void BufferCache<P>::UpdateComputeUniformBuffers() {
|
|||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::UpdateComputeStorageBuffers() {
|
void BufferCache<P>::UpdateComputeStorageBuffers() {
|
||||||
ForEachEnabledBit(channel_state->enabled_compute_storage_buffers, [&](u32 index) {
|
ForEachEnabledBit(channel_state->enabled_compute_storage_buffers, [&](u32 index) {
|
||||||
// Resolve buffer
|
UpdateStorageBuffer(channel_state->compute_storage_buffers[index]);
|
||||||
Binding& binding = channel_state->compute_storage_buffers[index];
|
|
||||||
binding.buffer_id = FindBuffer(binding.device_addr, binding.size);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class P>
|
||||||
|
void BufferCache<P>::UpdateStorageBuffer(StorageBufferBindingInfo& binding) {
|
||||||
|
binding.segments.clear();
|
||||||
|
if (binding.gpu_addr == 0 || binding.size == 0) { return;}
|
||||||
|
if (binding.descriptor_count == 1) {
|
||||||
|
// for safety gotta preserve the legacy path on possible hosts without storage-buffer descriptor indexing.
|
||||||
|
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(binding.gpu_addr);
|
||||||
|
if (device_addr) {
|
||||||
|
binding.segments.push_back(Binding{
|
||||||
|
.device_addr = *device_addr,
|
||||||
|
.size = binding.size,
|
||||||
|
.buffer_id = FindBuffer(*device_addr, binding.size),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ranges = gpu_memory->GetSubmappedRange(binding.gpu_addr, binding.size);
|
||||||
|
const size_t mapped_size =
|
||||||
|
std::accumulate(ranges.begin(), ranges.end(), size_t{}, [](size_t total, const auto& range) { return total + range.second; });
|
||||||
|
if (mapped_size != binding.size) {
|
||||||
|
LOG_ERROR(HW_GPU, "Storage buffer range {:#x}+{:#x} is not fully mapped", binding.gpu_addr, binding.size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ranges.size() > binding.descriptor_count) {
|
||||||
|
LOG_ERROR(HW_GPU, "Storage buffer range {:#x}+{:#x} has {} physical segments, exceeding host capacity {}",
|
||||||
|
binding.gpu_addr, binding.size, ranges.size(), binding.descriptor_count);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const auto& [gpu_addr, size] : ranges) {
|
||||||
|
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr);
|
||||||
|
if (!device_addr || size > (std::numeric_limits<u32>::max)()) {
|
||||||
|
binding.segments.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const u32 segment_size = static_cast<u32>(size);
|
||||||
|
binding.segments.push_back(Binding{
|
||||||
|
.device_addr = *device_addr,
|
||||||
|
.size = segment_size,
|
||||||
|
.buffer_id = FindBuffer(*device_addr, segment_size),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::UpdateComputeTextureBuffers() {
|
void BufferCache<P>::UpdateComputeTextureBuffers() {
|
||||||
ForEachEnabledBit(channel_state->enabled_compute_texture_buffers, [&](u32 index) {
|
ForEachEnabledBit(channel_state->enabled_compute_texture_buffers, [&](u32 index) {
|
||||||
@@ -1692,10 +1669,9 @@ template <class P>
|
|||||||
BufferId BufferCache<P>::CreateBuffer(DAddr device_addr, u32 wanted_size) {
|
BufferId BufferCache<P>::CreateBuffer(DAddr device_addr, u32 wanted_size) {
|
||||||
DAddr device_addr_end = Common::AlignUp(device_addr + wanted_size, CACHING_PAGESIZE);
|
DAddr device_addr_end = Common::AlignUp(device_addr + wanted_size, CACHING_PAGESIZE);
|
||||||
device_addr = Common::AlignDown(device_addr, CACHING_PAGESIZE);
|
device_addr = Common::AlignDown(device_addr, CACHING_PAGESIZE);
|
||||||
constexpr u64 max_buffer_size = u64{(std::numeric_limits<u32>::max)()};
|
wanted_size = static_cast<u32>(device_addr_end - device_addr);
|
||||||
wanted_size = static_cast<u32>((std::min)(device_addr_end - device_addr, max_buffer_size));
|
|
||||||
const OverlapResult overlap = ResolveOverlaps(device_addr, wanted_size);
|
const OverlapResult overlap = ResolveOverlaps(device_addr, wanted_size);
|
||||||
const u32 size = static_cast<u32>((std::min)(overlap.end - overlap.begin, max_buffer_size));
|
const u32 size = static_cast<u32>(overlap.end - overlap.begin);
|
||||||
const BufferId new_buffer_id = slot_buffers.insert(runtime, overlap.begin, size);
|
const BufferId new_buffer_id = slot_buffers.insert(runtime, overlap.begin, size);
|
||||||
auto& new_buffer = slot_buffers[new_buffer_id];
|
auto& new_buffer = slot_buffers[new_buffer_id];
|
||||||
const size_t size_bytes = new_buffer.SizeBytes();
|
const size_t size_bytes = new_buffer.SizeBytes();
|
||||||
@@ -1956,6 +1932,11 @@ void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) {
|
|||||||
const auto replace = [scalar_replace](std::span<Binding> bindings) {
|
const auto replace = [scalar_replace](std::span<Binding> bindings) {
|
||||||
std::ranges::for_each(bindings, scalar_replace);
|
std::ranges::for_each(bindings, scalar_replace);
|
||||||
};
|
};
|
||||||
|
const auto storage_replace = [scalar_replace](std::span<StorageBufferBindingInfo> bindings) {
|
||||||
|
for (StorageBufferBindingInfo& binding : bindings) {
|
||||||
|
std::ranges::for_each(binding.segments, scalar_replace);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (channel_state->index_buffer.buffer_id == buffer_id) {
|
if (channel_state->index_buffer.buffer_id == buffer_id) {
|
||||||
channel_state->index_buffer.buffer_id = BufferId{};
|
channel_state->index_buffer.buffer_id = BufferId{};
|
||||||
@@ -1971,10 +1952,10 @@ void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::ranges::for_each(channel_state->uniform_buffers, replace);
|
std::ranges::for_each(channel_state->uniform_buffers, replace);
|
||||||
std::ranges::for_each(channel_state->storage_buffers, replace);
|
std::ranges::for_each(channel_state->storage_buffers, storage_replace);
|
||||||
replace(channel_state->transform_feedback_buffers);
|
replace(channel_state->transform_feedback_buffers);
|
||||||
replace(channel_state->compute_uniform_buffers);
|
replace(channel_state->compute_uniform_buffers);
|
||||||
replace(channel_state->compute_storage_buffers);
|
storage_replace(channel_state->compute_storage_buffers);
|
||||||
|
|
||||||
// Mark the whole buffer as CPU written to stop tracking CPU writes
|
// Mark the whole buffer as CPU written to stop tracking CPU writes
|
||||||
if (!do_not_mark) {
|
if (!do_not_mark) {
|
||||||
@@ -2011,12 +1992,14 @@ void BufferCache<P>::DeleteBuffer(BufferId buffer_id, bool do_not_mark) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
|
StorageBufferBindingInfo BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
|
||||||
bool is_written) const {
|
bool is_written, u32 descriptor_count) const {
|
||||||
|
// time to get rid of these null bindings
|
||||||
|
ASSERT(descriptor_count > 0); // shant happen
|
||||||
const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr);
|
const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr);
|
||||||
|
|
||||||
if (gpu_addr == 0) {
|
if (gpu_addr == 0) {
|
||||||
return NULL_BINDING;
|
return {.descriptor_count = descriptor_count};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto size = [&]() {
|
const auto size = [&]() {
|
||||||
@@ -2038,21 +2021,17 @@ Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
|
|||||||
const GPUVAddr aligned_gpu_addr = Common::AlignDown(gpu_addr, alignment);
|
const GPUVAddr aligned_gpu_addr = Common::AlignDown(gpu_addr, alignment);
|
||||||
const u32 aligned_size = static_cast<u32>(gpu_addr - aligned_gpu_addr) + size;
|
const u32 aligned_size = static_cast<u32>(gpu_addr - aligned_gpu_addr) + size;
|
||||||
|
|
||||||
const std::optional<DAddr> aligned_device_addr = gpu_memory->GpuToCpuAddress(aligned_gpu_addr);
|
if (!gpu_memory->GpuToCpuAddress(aligned_gpu_addr) || size == 0) {
|
||||||
if (!aligned_device_addr || size == 0) {
|
|
||||||
LOG_DEBUG(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index);
|
LOG_DEBUG(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index);
|
||||||
return NULL_BINDING;
|
return {.descriptor_count = descriptor_count};
|
||||||
}
|
}
|
||||||
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr);
|
|
||||||
ASSERT_MSG(device_addr, "Unaligned storage buffer address not found for cbuf index {}",
|
|
||||||
cbuf_index);
|
|
||||||
// The end address used for size calculation does not need to be aligned
|
// The end address used for size calculation does not need to be aligned
|
||||||
const DAddr cpu_end = Common::AlignUp(*device_addr + size, Core::DEVICE_PAGESIZE);
|
const GPUVAddr gpu_end = Common::AlignUp(gpu_addr + size, Core::DEVICE_PAGESIZE);
|
||||||
|
|
||||||
const Binding binding{
|
const StorageBufferBindingInfo binding{
|
||||||
.device_addr = *aligned_device_addr,
|
.gpu_addr = aligned_gpu_addr,
|
||||||
.size = is_written ? aligned_size : static_cast<u32>(cpu_end - *aligned_device_addr),
|
.size = is_written ? aligned_size : static_cast<u32>(gpu_end - aligned_gpu_addr),
|
||||||
.buffer_id = BufferId{},
|
.descriptor_count = descriptor_count,
|
||||||
};
|
};
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ constexpr u32 NUM_VERTEX_BUFFERS = 16;
|
|||||||
#else
|
#else
|
||||||
constexpr u32 NUM_VERTEX_BUFFERS = 32;
|
constexpr u32 NUM_VERTEX_BUFFERS = 32;
|
||||||
#endif
|
#endif
|
||||||
constexpr u64 IMPLAUSIBLE_VERTEX_SIZE = 64_MiB;
|
|
||||||
constexpr u32 NUM_TRANSFORM_FEEDBACK_BUFFERS = 4;
|
constexpr u32 NUM_TRANSFORM_FEEDBACK_BUFFERS = 4;
|
||||||
constexpr u32 NUM_GRAPHICS_UNIFORM_BUFFERS = 18;
|
constexpr u32 NUM_GRAPHICS_UNIFORM_BUFFERS = 18;
|
||||||
constexpr u32 NUM_COMPUTE_UNIFORM_BUFFERS = 8;
|
constexpr u32 NUM_COMPUTE_UNIFORM_BUFFERS = 8;
|
||||||
@@ -90,6 +89,15 @@ struct TextureBufferBinding : Binding {
|
|||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct StorageBufferBindingInfo {
|
||||||
|
// another good one: guest SSBO is a virtual interval and may span discontiguous device-memory ranges.
|
||||||
|
// exact case of missing character frames (high sample lane)
|
||||||
|
GPUVAddr gpu_addr{};
|
||||||
|
u32 size{};
|
||||||
|
u32 descriptor_count{1};
|
||||||
|
boost::container::small_vector<Binding, 1> segments;
|
||||||
|
};
|
||||||
|
|
||||||
static constexpr Binding NULL_BINDING{
|
static constexpr Binding NULL_BINDING{
|
||||||
.device_addr = 0,
|
.device_addr = 0,
|
||||||
.size = 0,
|
.size = 0,
|
||||||
@@ -116,14 +124,15 @@ public:
|
|||||||
Binding index_buffer;
|
Binding index_buffer;
|
||||||
std::array<Binding, NUM_VERTEX_BUFFERS> vertex_buffers;
|
std::array<Binding, NUM_VERTEX_BUFFERS> vertex_buffers;
|
||||||
std::array<std::array<Binding, NUM_GRAPHICS_UNIFORM_BUFFERS>, NUM_STAGES> uniform_buffers;
|
std::array<std::array<Binding, NUM_GRAPHICS_UNIFORM_BUFFERS>, NUM_STAGES> uniform_buffers;
|
||||||
std::array<std::array<Binding, NUM_STORAGE_BUFFERS>, NUM_STAGES> storage_buffers;
|
std::array<std::array<StorageBufferBindingInfo, NUM_STORAGE_BUFFERS>, NUM_STAGES>
|
||||||
|
storage_buffers;
|
||||||
std::array<std::array<TextureBufferBinding, NUM_TEXTURE_BUFFERS>, NUM_STAGES> texture_buffers;
|
std::array<std::array<TextureBufferBinding, NUM_TEXTURE_BUFFERS>, NUM_STAGES> texture_buffers;
|
||||||
std::array<Binding, NUM_TRANSFORM_FEEDBACK_BUFFERS> transform_feedback_buffers;
|
std::array<Binding, NUM_TRANSFORM_FEEDBACK_BUFFERS> transform_feedback_buffers;
|
||||||
Binding count_buffer_binding;
|
Binding count_buffer_binding;
|
||||||
Binding indirect_buffer_binding;
|
Binding indirect_buffer_binding;
|
||||||
|
|
||||||
std::array<Binding, NUM_COMPUTE_UNIFORM_BUFFERS> compute_uniform_buffers;
|
std::array<Binding, NUM_COMPUTE_UNIFORM_BUFFERS> compute_uniform_buffers;
|
||||||
std::array<Binding, NUM_STORAGE_BUFFERS> compute_storage_buffers;
|
std::array<StorageBufferBindingInfo, NUM_STORAGE_BUFFERS> compute_storage_buffers;
|
||||||
std::array<TextureBufferBinding, NUM_TEXTURE_BUFFERS> compute_texture_buffers;
|
std::array<TextureBufferBinding, NUM_TEXTURE_BUFFERS> compute_texture_buffers;
|
||||||
|
|
||||||
std::array<u32, NUM_STAGES> enabled_uniform_buffer_masks{};
|
std::array<u32, NUM_STAGES> enabled_uniform_buffer_masks{};
|
||||||
@@ -218,6 +227,8 @@ public:
|
|||||||
|
|
||||||
void WriteMemory(DAddr device_addr, u64 size);
|
void WriteMemory(DAddr device_addr, u64 size);
|
||||||
|
|
||||||
|
void CachedWriteMemory(DAddr device_addr, u64 size);
|
||||||
|
|
||||||
bool OnCPUWrite(DAddr device_addr, u64 size);
|
bool OnCPUWrite(DAddr device_addr, u64 size);
|
||||||
|
|
||||||
void DownloadMemory(DAddr device_addr, u64 size);
|
void DownloadMemory(DAddr device_addr, u64 size);
|
||||||
@@ -247,8 +258,8 @@ public:
|
|||||||
|
|
||||||
void UnbindGraphicsStorageBuffers(size_t stage);
|
void UnbindGraphicsStorageBuffers(size_t stage);
|
||||||
|
|
||||||
void BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, u32 cbuf_index, u32 cbuf_offset,
|
bool BindGraphicsStorageBuffer(size_t stage, size_t ssbo_index, u32 cbuf_index, u32 cbuf_offset,
|
||||||
bool is_written);
|
bool is_written, u32 descriptor_count = 1);
|
||||||
|
|
||||||
void UnbindGraphicsTextureBuffers(size_t stage);
|
void UnbindGraphicsTextureBuffers(size_t stage);
|
||||||
|
|
||||||
@@ -258,7 +269,7 @@ public:
|
|||||||
void UnbindComputeStorageBuffers();
|
void UnbindComputeStorageBuffers();
|
||||||
|
|
||||||
void BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index, u32 cbuf_offset,
|
void BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index, u32 cbuf_offset,
|
||||||
bool is_written);
|
bool is_written, u32 descriptor_count = 1);
|
||||||
|
|
||||||
void UnbindComputeTextureBuffers();
|
void UnbindComputeTextureBuffers();
|
||||||
|
|
||||||
@@ -308,10 +319,6 @@ public:
|
|||||||
current_draw_indirect = current_draw_indirect_;
|
current_draw_indirect = current_draw_indirect_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDrawInstanceCount(u32 draw_instance_count_) {
|
|
||||||
draw_instance_count = draw_instance_count_;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::pair<Buffer*, u32> GetDrawIndirectCount();
|
[[nodiscard]] std::pair<Buffer*, u32> GetDrawIndirectCount();
|
||||||
|
|
||||||
[[nodiscard]] std::pair<Buffer*, u32> GetDrawIndirectBuffer();
|
[[nodiscard]] std::pair<Buffer*, u32> GetDrawIndirectBuffer();
|
||||||
@@ -379,6 +386,8 @@ private:
|
|||||||
|
|
||||||
void BindHostTransformFeedbackBuffers();
|
void BindHostTransformFeedbackBuffers();
|
||||||
|
|
||||||
|
void BindHostVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride);
|
||||||
|
|
||||||
void BindHostComputeUniformBuffers();
|
void BindHostComputeUniformBuffers();
|
||||||
|
|
||||||
void BindHostComputeStorageBuffers();
|
void BindHostComputeStorageBuffers();
|
||||||
@@ -391,15 +400,9 @@ private:
|
|||||||
|
|
||||||
void UpdateIndexBuffer();
|
void UpdateIndexBuffer();
|
||||||
|
|
||||||
void UpdateVertexBuffers(bool is_indexed);
|
void UpdateVertexBuffers();
|
||||||
|
|
||||||
void UpdateVertexBuffer(u32 index, bool is_indexed);
|
void UpdateVertexBuffer(u32 index);
|
||||||
|
|
||||||
[[nodiscard]] u64 DrawVertexBound(u32 index, bool is_indexed);
|
|
||||||
|
|
||||||
[[nodiscard]] u64 DrawMaxIndex();
|
|
||||||
|
|
||||||
[[nodiscard]] u64 StreamAttributeExtent(u32 index);
|
|
||||||
|
|
||||||
void UpdateDrawIndirect();
|
void UpdateDrawIndirect();
|
||||||
|
|
||||||
@@ -407,6 +410,8 @@ private:
|
|||||||
|
|
||||||
void UpdateStorageBuffers(size_t stage);
|
void UpdateStorageBuffers(size_t stage);
|
||||||
|
|
||||||
|
void UpdateStorageBuffer(StorageBufferBindingInfo& binding);
|
||||||
|
|
||||||
void UpdateTextureBuffers(size_t stage);
|
void UpdateTextureBuffers(size_t stage);
|
||||||
|
|
||||||
void UpdateTransformFeedbackBuffers();
|
void UpdateTransformFeedbackBuffers();
|
||||||
@@ -456,8 +461,9 @@ private:
|
|||||||
|
|
||||||
void DeleteBuffer(BufferId buffer_id, bool do_not_mark = false);
|
void DeleteBuffer(BufferId buffer_id, bool do_not_mark = false);
|
||||||
|
|
||||||
[[nodiscard]] Binding StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
|
[[nodiscard]] StorageBufferBindingInfo StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
|
||||||
bool is_written) const;
|
bool is_written,
|
||||||
|
u32 descriptor_count) const;
|
||||||
|
|
||||||
[[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size,
|
[[nodiscard]] TextureBufferBinding GetTextureBufferBinding(GPUVAddr gpu_addr, u32 size,
|
||||||
PixelFormat format);
|
PixelFormat format);
|
||||||
@@ -491,14 +497,6 @@ private:
|
|||||||
|
|
||||||
const Tegra::Engines::Maxwell3D::DrawManager::IndirectParams* current_draw_indirect{};
|
const Tegra::Engines::Maxwell3D::DrawManager::IndirectParams* current_draw_indirect{};
|
||||||
|
|
||||||
u32 draw_instance_count = 0;
|
|
||||||
std::array<u64, NUM_VERTEX_BUFFERS> last_draw_bounds{};
|
|
||||||
Common::ScratchBuffer<u32> index_scan_buffer;
|
|
||||||
u64 cached_max_index = 0;
|
|
||||||
bool max_index_scanned = false;
|
|
||||||
std::array<u64, NUM_VERTEX_BUFFERS> stream_extents{};
|
|
||||||
bool stream_extents_valid = false;
|
|
||||||
|
|
||||||
u32 last_index_count = 0;
|
u32 last_index_count = 0;
|
||||||
|
|
||||||
u32 enabled_vertex_buffers_mask = 0;
|
u32 enabled_vertex_buffers_mask = 0;
|
||||||
|
|||||||
@@ -206,40 +206,6 @@ foreach(VARIANT IN ITEMS ${SHADER_TYPE_VARIANTS})
|
|||||||
set(SHADER_HEADERS ${SHADER_HEADERS} ${VARIANT_HEADER_FILE})
|
set(SHADER_HEADERS ${SHADER_HEADERS} ${VARIANT_HEADER_FILE})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(SHADER_DEFINE_VARIANTS
|
|
||||||
"block_linear_unswizzle_2d.comp|nonarrow|HAS_EXTENDED_TYPES=0"
|
|
||||||
"pitch_unswizzle.comp|nonarrow|HAS_EXTENDED_TYPES=0"
|
|
||||||
"block_linear_unswizzle_3d.comp|nonarrow|HAS_EXTENDED_TYPES=0"
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach(VARIANT IN ITEMS ${SHADER_DEFINE_VARIANTS})
|
|
||||||
string(REPLACE "|" ";" VARIANT_PARTS ${VARIANT})
|
|
||||||
list(GET VARIANT_PARTS 0 VARIANT_FILENAME)
|
|
||||||
list(GET VARIANT_PARTS 1 VARIANT_SUFFIX)
|
|
||||||
list(GET VARIANT_PARTS 2 VARIANT_DEFINE)
|
|
||||||
|
|
||||||
set(VARIANT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/${VARIANT_FILENAME})
|
|
||||||
get_filename_component(VARIANT_STEM ${VARIANT_FILENAME} NAME_WE)
|
|
||||||
get_filename_component(VARIANT_EXT ${VARIANT_FILENAME} EXT)
|
|
||||||
string(REPLACE "." "" VARIANT_EXT ${VARIANT_EXT})
|
|
||||||
set(VARIANT_NAME ${VARIANT_STEM}_${VARIANT_SUFFIX}_${VARIANT_EXT})
|
|
||||||
|
|
||||||
string(TOUPPER ${VARIANT_NAME}_SPV VARIANT_VARIABLE_NAME)
|
|
||||||
set(VARIANT_HEADER_FILE ${SHADER_DIR}/${VARIANT_NAME}_spv.h)
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT
|
|
||||||
${VARIANT_HEADER_FILE}
|
|
||||||
COMMAND
|
|
||||||
${GLSLANGVALIDATOR} -V ${QUIET_FLAG} -I"${FIDELITYFX_INCLUDE_DIR}" ${GLSL_FLAGS}
|
|
||||||
-D${VARIANT_DEFINE}
|
|
||||||
--variable-name ${VARIANT_VARIABLE_NAME} -o ${VARIANT_HEADER_FILE} ${VARIANT_SOURCE}
|
|
||||||
--target-env ${SPIR_V_VERSION}
|
|
||||||
MAIN_DEPENDENCY
|
|
||||||
${VARIANT_SOURCE}
|
|
||||||
)
|
|
||||||
set(SHADER_HEADERS ${SHADER_HEADERS} ${VARIANT_HEADER_FILE})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
foreach(FILEPATH IN ITEMS ${FIDELITYFX_FILES})
|
foreach(FILEPATH IN ITEMS ${FIDELITYFX_FILES})
|
||||||
get_filename_component(FILENAME ${FILEPATH} NAME)
|
get_filename_component(FILENAME ${FILEPATH} NAME)
|
||||||
string(REPLACE "." "_" HEADER_NAME ${FILENAME})
|
string(REPLACE "." "_" HEADER_NAME ${FILENAME})
|
||||||
|
|||||||
@@ -5,13 +5,9 @@
|
|||||||
|
|
||||||
#ifdef VULKAN
|
#ifdef VULKAN
|
||||||
|
|
||||||
#ifndef HAS_EXTENDED_TYPES
|
|
||||||
#define HAS_EXTENDED_TYPES 1
|
|
||||||
#endif
|
|
||||||
#if HAS_EXTENDED_TYPES
|
|
||||||
#extension GL_EXT_shader_16bit_storage : require
|
#extension GL_EXT_shader_16bit_storage : require
|
||||||
#extension GL_EXT_shader_8bit_storage : require
|
#extension GL_EXT_shader_8bit_storage : require
|
||||||
#endif
|
#define HAS_EXTENDED_TYPES 1
|
||||||
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
||||||
#define END_PUSH_CONSTANTS };
|
#define END_PUSH_CONSTANTS };
|
||||||
#define UNIFORM(n)
|
#define UNIFORM(n)
|
||||||
|
|||||||
@@ -5,13 +5,9 @@
|
|||||||
|
|
||||||
#ifdef VULKAN
|
#ifdef VULKAN
|
||||||
|
|
||||||
#ifndef HAS_EXTENDED_TYPES
|
|
||||||
#define HAS_EXTENDED_TYPES 1
|
|
||||||
#endif
|
|
||||||
#if HAS_EXTENDED_TYPES
|
|
||||||
#extension GL_EXT_shader_16bit_storage : require
|
#extension GL_EXT_shader_16bit_storage : require
|
||||||
#extension GL_EXT_shader_8bit_storage : require
|
#extension GL_EXT_shader_8bit_storage : require
|
||||||
#endif
|
#define HAS_EXTENDED_TYPES 1
|
||||||
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
||||||
#define END_PUSH_CONSTANTS };
|
#define END_PUSH_CONSTANTS };
|
||||||
#define UNIFORM(n)
|
#define UNIFORM(n)
|
||||||
|
|||||||
@@ -5,13 +5,9 @@
|
|||||||
|
|
||||||
#ifdef VULKAN
|
#ifdef VULKAN
|
||||||
|
|
||||||
#ifndef HAS_EXTENDED_TYPES
|
|
||||||
#define HAS_EXTENDED_TYPES 1
|
|
||||||
#endif
|
|
||||||
#if HAS_EXTENDED_TYPES
|
|
||||||
#extension GL_EXT_shader_16bit_storage : require
|
#extension GL_EXT_shader_16bit_storage : require
|
||||||
#extension GL_EXT_shader_8bit_storage : require
|
#extension GL_EXT_shader_8bit_storage : require
|
||||||
#endif
|
#define HAS_EXTENDED_TYPES 1
|
||||||
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
#define BEGIN_PUSH_CONSTANTS layout(push_constant) uniform PushConstants {
|
||||||
#define END_PUSH_CONSTANTS };
|
#define END_PUSH_CONSTANTS };
|
||||||
#define UNIFORM(n)
|
#define UNIFORM(n)
|
||||||
|
|||||||
@@ -226,6 +226,22 @@ void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufferCacheRuntime::BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size,
|
||||||
|
u32 stride) {
|
||||||
|
if (index >= max_attributes) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (has_unified_vertex_buffers) {
|
||||||
|
buffer.MakeResident(GL_READ_ONLY);
|
||||||
|
glBindVertexBuffer(index, 0, 0, static_cast<GLsizei>(stride));
|
||||||
|
glBufferAddressRangeNV(GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV, index,
|
||||||
|
buffer.HostGpuAddr() + offset, static_cast<GLsizeiptr>(size));
|
||||||
|
} else {
|
||||||
|
glBindVertexBuffer(index, buffer.Handle(), static_cast<GLintptr>(offset),
|
||||||
|
static_cast<GLsizei>(stride));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
||||||
// TODO: Should HostBindings provide the correct runtime types to avoid these transforms?
|
// TODO: Should HostBindings provide the correct runtime types to avoid these transforms?
|
||||||
std::array<GLuint, 32> buffer_handles;
|
std::array<GLuint, 32> buffer_handles;
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ public:
|
|||||||
|
|
||||||
void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size);
|
void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size);
|
||||||
|
|
||||||
|
void BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride);
|
||||||
|
|
||||||
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
void BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, u32 offset, u32 size);
|
void BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, u32 offset, u32 size);
|
||||||
|
|||||||
@@ -259,7 +259,6 @@ void RasterizerOpenGL::PrepareDraw(bool is_indexed, Func&& draw_func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::Draw(bool is_indexed, u32 instance_count) {
|
void RasterizerOpenGL::Draw(bool is_indexed, u32 instance_count) {
|
||||||
buffer_cache.SetDrawInstanceCount(instance_count);
|
|
||||||
PrepareDraw(is_indexed, [this, is_indexed, instance_count](GLenum primitive_mode) {
|
PrepareDraw(is_indexed, [this, is_indexed, instance_count](GLenum primitive_mode) {
|
||||||
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
const auto& draw_state = maxwell3d->draw_manager.draw_state;
|
||||||
const GLuint base_instance = GLuint(draw_state.base_instance);
|
const GLuint base_instance = GLuint(draw_state.base_instance);
|
||||||
@@ -305,7 +304,6 @@ void RasterizerOpenGL::Draw(bool is_indexed, u32 instance_count) {
|
|||||||
void RasterizerOpenGL::DrawIndirect() {
|
void RasterizerOpenGL::DrawIndirect() {
|
||||||
const auto& params = maxwell3d->draw_manager.indirect_state;
|
const auto& params = maxwell3d->draw_manager.indirect_state;
|
||||||
buffer_cache.SetDrawIndirect(¶ms);
|
buffer_cache.SetDrawIndirect(¶ms);
|
||||||
buffer_cache.SetDrawInstanceCount(0);
|
|
||||||
PrepareDraw(params.is_indexed, [this, ¶ms](GLenum primitive_mode) {
|
PrepareDraw(params.is_indexed, [this, ¶ms](GLenum primitive_mode) {
|
||||||
if (params.is_byte_count) {
|
if (params.is_byte_count) {
|
||||||
const GPUVAddr tfb_object_base_addr = params.indirect_start_address - 4U;
|
const GPUVAddr tfb_object_base_addr = params.indirect_start_address - 4U;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
@@ -136,6 +137,7 @@ inline void WriteDescriptorBuffer(const Device& device, const DescriptorBufferLa
|
|||||||
|
|
||||||
[[nodiscard]] inline u32 NumDescriptorEntries(const Shader::Info& info) {
|
[[nodiscard]] inline u32 NumDescriptorEntries(const Shader::Info& info) {
|
||||||
return Shader::NumDescriptors(info.constant_buffer_descriptors) +
|
return Shader::NumDescriptors(info.constant_buffer_descriptors) +
|
||||||
|
static_cast<u32>(Shader::UsesStorageBufferMappings(info)) +
|
||||||
Shader::NumDescriptors(info.storage_buffers_descriptors) +
|
Shader::NumDescriptors(info.storage_buffers_descriptors) +
|
||||||
Shader::NumDescriptors(info.texture_buffer_descriptors) +
|
Shader::NumDescriptors(info.texture_buffer_descriptors) +
|
||||||
Shader::NumDescriptors(info.image_buffer_descriptors) +
|
Shader::NumDescriptors(info.image_buffer_descriptors) +
|
||||||
@@ -268,6 +270,12 @@ public:
|
|||||||
is_compute |= (stage & VK_SHADER_STAGE_COMPUTE_BIT) != 0;
|
is_compute |= (stage & VK_SHADER_STAGE_COMPUTE_BIT) != 0;
|
||||||
|
|
||||||
Add(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, stage, info.constant_buffer_descriptors);
|
Add(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, stage, info.constant_buffer_descriptors);
|
||||||
|
// for extra implicit storage-buffer binding required by mapped-storage-buffer support
|
||||||
|
if (Shader::UsesStorageBufferMappings(info)) {
|
||||||
|
struct Descriptor { u32 count; };
|
||||||
|
const std::array descriptors{Descriptor{1}};
|
||||||
|
Add(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, stage, descriptors);
|
||||||
|
}
|
||||||
Add(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, stage, info.storage_buffers_descriptors);
|
Add(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, stage, info.storage_buffers_descriptors);
|
||||||
Add(VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, stage, info.texture_buffer_descriptors);
|
Add(VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, stage, info.texture_buffer_descriptors);
|
||||||
Add(VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, stage, info.image_buffer_descriptors);
|
Add(VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, stage, info.image_buffer_descriptors);
|
||||||
|
|||||||
@@ -585,6 +585,29 @@ void BufferCacheRuntime::BindQuadIndexBuffer(PrimitiveTopology topology, u32 fir
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride) {
|
||||||
|
if (index >= device.GetMaxVertexInputBindings()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (device.IsExtExtendedDynamicStateSupported()) {
|
||||||
|
scheduler.Record([index, buffer, offset, size, stride](vk::CommandBuffer cmdbuf) {
|
||||||
|
const VkDeviceSize vk_offset = buffer != VK_NULL_HANDLE ? offset : 0;
|
||||||
|
const VkDeviceSize vk_size = buffer != VK_NULL_HANDLE ? size : VK_WHOLE_SIZE;
|
||||||
|
const VkDeviceSize vk_stride = stride;
|
||||||
|
cmdbuf.BindVertexBuffers2EXT(index, 1, &buffer, &vk_offset, &vk_size, &vk_stride);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (!device.HasNullDescriptor() && buffer == VK_NULL_HANDLE) {
|
||||||
|
ReserveNullBuffer();
|
||||||
|
buffer = *null_buffer;
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
scheduler.Record([index, buffer, offset](vk::CommandBuffer cmdbuf) {
|
||||||
|
cmdbuf.BindVertexBuffer(index, buffer, offset);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
||||||
boost::container::static_vector<VkBuffer, VideoCommon::NUM_VERTEX_BUFFERS> buffer_handles(bindings.buffers.size());
|
boost::container::static_vector<VkBuffer, VideoCommon::NUM_VERTEX_BUFFERS> buffer_handles(bindings.buffers.size());
|
||||||
for (u32 i = 0; i < bindings.buffers.size(); ++i) {
|
for (u32 i = 0; i < bindings.buffers.size(); ++i) {
|
||||||
@@ -672,7 +695,7 @@ vk::Buffer BufferCacheRuntime::CreateNullBuffer() {
|
|||||||
.flags = 0,
|
.flags = 0,
|
||||||
.size = 4,
|
.size = 4,
|
||||||
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT |
|
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT |
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT,
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
|
||||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
.queueFamilyIndexCount = 0,
|
.queueFamilyIndexCount = 0,
|
||||||
.pQueueFamilyIndices = nullptr,
|
.pQueueFamilyIndices = nullptr,
|
||||||
|
|||||||
@@ -138,6 +138,8 @@ public:
|
|||||||
|
|
||||||
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
|
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
|
||||||
|
|
||||||
|
void BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride);
|
||||||
|
|
||||||
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size);
|
void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size);
|
||||||
@@ -153,6 +155,13 @@ public:
|
|||||||
return ref.mapped_span;
|
return ref.mapped_span;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// compute/graphics new binding
|
||||||
|
std::span<u8> BindMappedStorageBuffer(u32 size) {
|
||||||
|
const StagingBufferRef ref = staging_pool.Request(size, MemoryUsage::Upload);
|
||||||
|
guest_descriptor_queue.AddBuffer(ref.buffer, ref.device_address, static_cast<u32>(ref.offset), size);
|
||||||
|
return ref.mapped_span;
|
||||||
|
}
|
||||||
|
|
||||||
void BindUniformBuffer(const Buffer& buffer, u32 offset, u32 size) {
|
void BindUniformBuffer(const Buffer& buffer, u32 offset, u32 size) {
|
||||||
BindBuffer(buffer, offset, size);
|
BindBuffer(buffer, offset, size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,13 +22,7 @@
|
|||||||
#include "video_core/host_shaders/resolve_conditional_render_comp_spv.h"
|
#include "video_core/host_shaders/resolve_conditional_render_comp_spv.h"
|
||||||
#include "video_core/host_shaders/vulkan_quad_indexed_comp_spv.h"
|
#include "video_core/host_shaders/vulkan_quad_indexed_comp_spv.h"
|
||||||
#include "video_core/host_shaders/vulkan_uint8_comp_spv.h"
|
#include "video_core/host_shaders/vulkan_uint8_comp_spv.h"
|
||||||
#include "video_core/host_shaders/block_linear_unswizzle_2d_comp_spv.h"
|
|
||||||
#include "video_core/host_shaders/block_linear_unswizzle_2d_nonarrow_comp_spv.h"
|
|
||||||
#include "video_core/host_shaders/block_linear_unswizzle_3d_bcn_comp_spv.h"
|
#include "video_core/host_shaders/block_linear_unswizzle_3d_bcn_comp_spv.h"
|
||||||
#include "video_core/host_shaders/block_linear_unswizzle_3d_comp_spv.h"
|
|
||||||
#include "video_core/host_shaders/block_linear_unswizzle_3d_nonarrow_comp_spv.h"
|
|
||||||
#include "video_core/host_shaders/pitch_unswizzle_comp_spv.h"
|
|
||||||
#include "video_core/host_shaders/pitch_unswizzle_nonarrow_comp_spv.h"
|
|
||||||
#include "video_core/renderer_vulkan/vk_compute_pass.h"
|
#include "video_core/renderer_vulkan/vk_compute_pass.h"
|
||||||
#include "video_core/surface.h"
|
#include "video_core/surface.h"
|
||||||
#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
|
#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
|
||||||
@@ -878,291 +872,4 @@ void BlockLinearUnswizzle3DPass::UnswizzleChunk(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
constexpr u32 UNSWIZZLE_BINDING_INPUT_BUFFER = 0;
|
|
||||||
constexpr u32 UNSWIZZLE_BINDING_OUTPUT_IMAGE = 1;
|
|
||||||
constexpr size_t UNSWIZZLE_NUM_BINDINGS = 2;
|
|
||||||
|
|
||||||
constexpr std::array<VkDescriptorSetLayoutBinding, UNSWIZZLE_NUM_BINDINGS>
|
|
||||||
UNSWIZZLE_DESCRIPTOR_SET_BINDINGS{{
|
|
||||||
{
|
|
||||||
.binding = UNSWIZZLE_BINDING_INPUT_BUFFER,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.pImmutableSamplers = nullptr,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.binding = UNSWIZZLE_BINDING_OUTPUT_IMAGE,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.pImmutableSamplers = nullptr,
|
|
||||||
},
|
|
||||||
}};
|
|
||||||
|
|
||||||
constexpr std::array<VkDescriptorUpdateTemplateEntry, UNSWIZZLE_NUM_BINDINGS>
|
|
||||||
UNSWIZZLE_DESCRIPTOR_UPDATE_TEMPLATE{{
|
|
||||||
{
|
|
||||||
.dstBinding = UNSWIZZLE_BINDING_INPUT_BUFFER,
|
|
||||||
.dstArrayElement = 0,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
|
||||||
.offset = UNSWIZZLE_BINDING_INPUT_BUFFER * sizeof(DescriptorUpdateEntry),
|
|
||||||
.stride = sizeof(DescriptorUpdateEntry),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.dstBinding = UNSWIZZLE_BINDING_OUTPUT_IMAGE,
|
|
||||||
.dstArrayElement = 0,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
|
||||||
.offset = UNSWIZZLE_BINDING_OUTPUT_IMAGE * sizeof(DescriptorUpdateEntry),
|
|
||||||
.stride = sizeof(DescriptorUpdateEntry),
|
|
||||||
},
|
|
||||||
}};
|
|
||||||
|
|
||||||
constexpr DescriptorBankInfo UNSWIZZLE_BANK_INFO{
|
|
||||||
.uniform_buffers = 0,
|
|
||||||
.storage_buffers = 1,
|
|
||||||
.texture_buffers = 0,
|
|
||||||
.image_buffers = 0,
|
|
||||||
.textures = 0,
|
|
||||||
.images = 1,
|
|
||||||
.score = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
[[nodiscard]] std::span<const u32> UnswizzleSpv(const Device& device,
|
|
||||||
std::span<const u32> extended,
|
|
||||||
std::span<const u32> narrow) {
|
|
||||||
if (device.IsStorageBuffer8BitAccessSupported() &&
|
|
||||||
device.IsStorageBuffer16BitAccessSupported()) {
|
|
||||||
return extended;
|
|
||||||
}
|
|
||||||
return narrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PitchUnswizzlePushConstants {
|
|
||||||
alignas(8) std::array<u32, 2> origin;
|
|
||||||
alignas(8) std::array<s32, 2> destination;
|
|
||||||
u32 bytes_per_block;
|
|
||||||
u32 pitch;
|
|
||||||
};
|
|
||||||
|
|
||||||
void RecordUnswizzleEntryBarrier(Scheduler& scheduler, VkPipeline vk_pipeline, VkImage vk_image,
|
|
||||||
VkImageAspectFlags aspect_mask, bool is_initialized) {
|
|
||||||
scheduler.Record([vk_pipeline, vk_image, aspect_mask,
|
|
||||||
is_initialized](vk::CommandBuffer cmdbuf) {
|
|
||||||
VkAccessFlags src_access = VK_ACCESS_NONE;
|
|
||||||
VkImageLayout old_layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
if (is_initialized) {
|
|
||||||
src_access = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT |
|
|
||||||
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
|
||||||
old_layout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
}
|
|
||||||
const VkImageMemoryBarrier image_barrier{
|
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
|
||||||
.pNext = nullptr,
|
|
||||||
.srcAccessMask = src_access,
|
|
||||||
.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
|
||||||
.oldLayout = old_layout,
|
|
||||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
|
||||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
|
||||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
|
||||||
.image = vk_image,
|
|
||||||
.subresourceRange{
|
|
||||||
.aspectMask = aspect_mask,
|
|
||||||
.baseMipLevel = 0,
|
|
||||||
.levelCount = VK_REMAINING_MIP_LEVELS,
|
|
||||||
.baseArrayLayer = 0,
|
|
||||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
VkPipelineStageFlags src_stage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
|
||||||
if (is_initialized) {
|
|
||||||
src_stage = vk::PIPELINE_STAGE_GRAPHICS_COMPUTE_TRANSFER;
|
|
||||||
}
|
|
||||||
cmdbuf.PipelineBarrier(src_stage, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, image_barrier);
|
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, vk_pipeline);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void RecordUnswizzleExitBarrier(Scheduler& scheduler, VkImage vk_image,
|
|
||||||
VkImageAspectFlags aspect_mask) {
|
|
||||||
scheduler.Record([vk_image, aspect_mask](vk::CommandBuffer cmdbuf) {
|
|
||||||
const VkImageMemoryBarrier image_barrier{
|
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
|
||||||
.pNext = nullptr,
|
|
||||||
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
|
|
||||||
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT |
|
|
||||||
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT,
|
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
|
||||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
|
||||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
|
||||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
|
||||||
.image = vk_image,
|
|
||||||
.subresourceRange{
|
|
||||||
.aspectMask = aspect_mask,
|
|
||||||
.baseMipLevel = 0,
|
|
||||||
.levelCount = VK_REMAINING_MIP_LEVELS,
|
|
||||||
.baseArrayLayer = 0,
|
|
||||||
.layerCount = VK_REMAINING_ARRAY_LAYERS,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
|
||||||
vk::PIPELINE_STAGE_GRAPHICS_COMPUTE_TRANSFER, 0, image_barrier);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Anonymous namespace
|
|
||||||
|
|
||||||
BlockLinearUnswizzle2DPass::BlockLinearUnswizzle2DPass(
|
|
||||||
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_)
|
|
||||||
: ComputePass(device_, scheduler_, descriptor_pool_, UNSWIZZLE_DESCRIPTOR_SET_BINDINGS,
|
|
||||||
UNSWIZZLE_DESCRIPTOR_UPDATE_TEMPLATE, UNSWIZZLE_BANK_INFO,
|
|
||||||
COMPUTE_PUSH_CONSTANT_RANGE<sizeof(
|
|
||||||
VideoCommon::Accelerated::BlockLinearSwizzle2DParams)>,
|
|
||||||
UnswizzleSpv(device_, BLOCK_LINEAR_UNSWIZZLE_2D_COMP_SPV,
|
|
||||||
BLOCK_LINEAR_UNSWIZZLE_2D_NONARROW_COMP_SPV)),
|
|
||||||
scheduler{scheduler_}, compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {}
|
|
||||||
|
|
||||||
BlockLinearUnswizzle2DPass::~BlockLinearUnswizzle2DPass() = default;
|
|
||||||
|
|
||||||
void BlockLinearUnswizzle2DPass::Unswizzle(
|
|
||||||
Image& image, const StagingBufferRef& map,
|
|
||||||
std::span<const VideoCommon::SwizzleParameters> swizzles) {
|
|
||||||
using namespace VideoCommon::Accelerated;
|
|
||||||
scheduler.RequestOutsideRenderPassOperationContext();
|
|
||||||
const VkPipeline vk_pipeline = *pipeline;
|
|
||||||
const VkImageAspectFlags aspect_mask = image.AspectMask();
|
|
||||||
const VkImage vk_image = image.Handle();
|
|
||||||
const bool is_initialized = image.ExchangeInitialization();
|
|
||||||
RecordUnswizzleEntryBarrier(scheduler, vk_pipeline, vk_image, aspect_mask, is_initialized);
|
|
||||||
|
|
||||||
const u32 num_layers = static_cast<u32>(image.info.resources.layers);
|
|
||||||
for (const VideoCommon::SwizzleParameters& swizzle : swizzles) {
|
|
||||||
const size_t input_offset = swizzle.buffer_offset + map.offset;
|
|
||||||
const u32 num_dispatches_x = Common::DivCeil(swizzle.num_tiles.width, 32U);
|
|
||||||
const u32 num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 32U);
|
|
||||||
|
|
||||||
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
|
||||||
compute_pass_descriptor_queue.AddBuffer(map.buffer, input_offset,
|
|
||||||
image.guest_size_bytes - swizzle.buffer_offset);
|
|
||||||
compute_pass_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
|
|
||||||
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
|
||||||
|
|
||||||
const auto params = MakeBlockLinearSwizzle2DParams(swizzle, image.info);
|
|
||||||
scheduler.Record([this, num_dispatches_x, num_dispatches_y, num_layers, params,
|
|
||||||
descriptor_data](vk::CommandBuffer cmdbuf) {
|
|
||||||
const VkDescriptorSet set = descriptor_allocator.Commit();
|
|
||||||
device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data);
|
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {});
|
|
||||||
cmdbuf.PushConstants(*layout, VK_SHADER_STAGE_COMPUTE_BIT, params);
|
|
||||||
cmdbuf.Dispatch(num_dispatches_x, num_dispatches_y, num_layers);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
RecordUnswizzleExitBarrier(scheduler, vk_image, aspect_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockLinearUnswizzleImage3DPass::BlockLinearUnswizzleImage3DPass(
|
|
||||||
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_)
|
|
||||||
: ComputePass(device_, scheduler_, descriptor_pool_, UNSWIZZLE_DESCRIPTOR_SET_BINDINGS,
|
|
||||||
UNSWIZZLE_DESCRIPTOR_UPDATE_TEMPLATE, UNSWIZZLE_BANK_INFO,
|
|
||||||
COMPUTE_PUSH_CONSTANT_RANGE<sizeof(BlockLinearSwizzle3DParams)>,
|
|
||||||
UnswizzleSpv(device_, BLOCK_LINEAR_UNSWIZZLE_3D_COMP_SPV,
|
|
||||||
BLOCK_LINEAR_UNSWIZZLE_3D_NONARROW_COMP_SPV)),
|
|
||||||
scheduler{scheduler_}, compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {}
|
|
||||||
|
|
||||||
BlockLinearUnswizzleImage3DPass::~BlockLinearUnswizzleImage3DPass() = default;
|
|
||||||
|
|
||||||
void BlockLinearUnswizzleImage3DPass::Unswizzle(
|
|
||||||
Image& image, const StagingBufferRef& map,
|
|
||||||
std::span<const VideoCommon::SwizzleParameters> swizzles) {
|
|
||||||
using namespace VideoCommon::Accelerated;
|
|
||||||
scheduler.RequestOutsideRenderPassOperationContext();
|
|
||||||
const VkPipeline vk_pipeline = *pipeline;
|
|
||||||
const VkImageAspectFlags aspect_mask = image.AspectMask();
|
|
||||||
const VkImage vk_image = image.Handle();
|
|
||||||
const bool is_initialized = image.ExchangeInitialization();
|
|
||||||
RecordUnswizzleEntryBarrier(scheduler, vk_pipeline, vk_image, aspect_mask, is_initialized);
|
|
||||||
|
|
||||||
for (const VideoCommon::SwizzleParameters& swizzle : swizzles) {
|
|
||||||
const size_t input_offset = swizzle.buffer_offset + map.offset;
|
|
||||||
const u32 num_dispatches_x = Common::DivCeil(swizzle.num_tiles.width, 16U);
|
|
||||||
const u32 num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 8U);
|
|
||||||
const u32 num_dispatches_z = Common::DivCeil(swizzle.num_tiles.depth, 8U);
|
|
||||||
|
|
||||||
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
|
||||||
compute_pass_descriptor_queue.AddBuffer(map.buffer, input_offset,
|
|
||||||
image.guest_size_bytes - swizzle.buffer_offset);
|
|
||||||
compute_pass_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
|
|
||||||
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
|
||||||
|
|
||||||
const auto params = MakeBlockLinearSwizzle3DParams(swizzle, image.info);
|
|
||||||
scheduler.Record([this, num_dispatches_x, num_dispatches_y, num_dispatches_z, params,
|
|
||||||
descriptor_data](vk::CommandBuffer cmdbuf) {
|
|
||||||
const VkDescriptorSet set = descriptor_allocator.Commit();
|
|
||||||
device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data);
|
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {});
|
|
||||||
cmdbuf.PushConstants(*layout, VK_SHADER_STAGE_COMPUTE_BIT, params);
|
|
||||||
cmdbuf.Dispatch(num_dispatches_x, num_dispatches_y, num_dispatches_z);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
RecordUnswizzleExitBarrier(scheduler, vk_image, aspect_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
PitchUnswizzlePass::PitchUnswizzlePass(
|
|
||||||
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_)
|
|
||||||
: ComputePass(device_, scheduler_, descriptor_pool_, UNSWIZZLE_DESCRIPTOR_SET_BINDINGS,
|
|
||||||
UNSWIZZLE_DESCRIPTOR_UPDATE_TEMPLATE, UNSWIZZLE_BANK_INFO,
|
|
||||||
COMPUTE_PUSH_CONSTANT_RANGE<sizeof(PitchUnswizzlePushConstants)>,
|
|
||||||
UnswizzleSpv(device_, PITCH_UNSWIZZLE_COMP_SPV,
|
|
||||||
PITCH_UNSWIZZLE_NONARROW_COMP_SPV)),
|
|
||||||
scheduler{scheduler_}, compute_pass_descriptor_queue{compute_pass_descriptor_queue_} {}
|
|
||||||
|
|
||||||
PitchUnswizzlePass::~PitchUnswizzlePass() = default;
|
|
||||||
|
|
||||||
void PitchUnswizzlePass::Unswizzle(Image& image, const StagingBufferRef& map,
|
|
||||||
std::span<const VideoCommon::SwizzleParameters> swizzles) {
|
|
||||||
scheduler.RequestOutsideRenderPassOperationContext();
|
|
||||||
const VkPipeline vk_pipeline = *pipeline;
|
|
||||||
const VkImageAspectFlags aspect_mask = image.AspectMask();
|
|
||||||
const VkImage vk_image = image.Handle();
|
|
||||||
const bool is_initialized = image.ExchangeInitialization();
|
|
||||||
RecordUnswizzleEntryBarrier(scheduler, vk_pipeline, vk_image, aspect_mask, is_initialized);
|
|
||||||
|
|
||||||
const u32 bytes_per_block = VideoCore::Surface::BytesPerBlock(image.info.format);
|
|
||||||
const u32 pitch = image.info.pitch;
|
|
||||||
for (const VideoCommon::SwizzleParameters& swizzle : swizzles) {
|
|
||||||
const size_t input_offset = swizzle.buffer_offset + map.offset;
|
|
||||||
const u32 num_dispatches_x = Common::DivCeil(swizzle.num_tiles.width, 32U);
|
|
||||||
const u32 num_dispatches_y = Common::DivCeil(swizzle.num_tiles.height, 32U);
|
|
||||||
|
|
||||||
compute_pass_descriptor_queue.Acquire(scheduler, 2);
|
|
||||||
compute_pass_descriptor_queue.AddBuffer(map.buffer, input_offset,
|
|
||||||
image.guest_size_bytes - swizzle.buffer_offset);
|
|
||||||
compute_pass_descriptor_queue.AddImage(image.StorageImageView(swizzle.level));
|
|
||||||
const void* const descriptor_data{compute_pass_descriptor_queue.UpdateData()};
|
|
||||||
|
|
||||||
const PitchUnswizzlePushConstants params{
|
|
||||||
.origin{0, 0},
|
|
||||||
.destination{0, 0},
|
|
||||||
.bytes_per_block = bytes_per_block,
|
|
||||||
.pitch = pitch,
|
|
||||||
};
|
|
||||||
scheduler.Record([this, num_dispatches_x, num_dispatches_y, params,
|
|
||||||
descriptor_data](vk::CommandBuffer cmdbuf) {
|
|
||||||
const VkDescriptorSet set = descriptor_allocator.Commit();
|
|
||||||
device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data);
|
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {});
|
|
||||||
cmdbuf.PushConstants(*layout, VK_SHADER_STAGE_COMPUTE_BIT, params);
|
|
||||||
cmdbuf.Dispatch(num_dispatches_x, num_dispatches_y, 1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
RecordUnswizzleExitBarrier(scheduler, vk_image, aspect_mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|||||||
@@ -164,49 +164,4 @@ private:
|
|||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BlockLinearUnswizzle2DPass final : public ComputePass {
|
|
||||||
public:
|
|
||||||
explicit BlockLinearUnswizzle2DPass(
|
|
||||||
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_);
|
|
||||||
~BlockLinearUnswizzle2DPass();
|
|
||||||
|
|
||||||
void Unswizzle(Image& image, const StagingBufferRef& map,
|
|
||||||
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Scheduler& scheduler;
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
|
||||||
};
|
|
||||||
|
|
||||||
class BlockLinearUnswizzleImage3DPass final : public ComputePass {
|
|
||||||
public:
|
|
||||||
explicit BlockLinearUnswizzleImage3DPass(
|
|
||||||
const Device& device_, Scheduler& scheduler_, DescriptorPool& descriptor_pool_,
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_);
|
|
||||||
~BlockLinearUnswizzleImage3DPass();
|
|
||||||
|
|
||||||
void Unswizzle(Image& image, const StagingBufferRef& map,
|
|
||||||
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Scheduler& scheduler;
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PitchUnswizzlePass final : public ComputePass {
|
|
||||||
public:
|
|
||||||
explicit PitchUnswizzlePass(const Device& device_, Scheduler& scheduler_,
|
|
||||||
DescriptorPool& descriptor_pool_,
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue_);
|
|
||||||
~PitchUnswizzlePass();
|
|
||||||
|
|
||||||
void Unswizzle(Image& image, const StagingBufferRef& map,
|
|
||||||
std::span<const VideoCommon::SwizzleParameters> swizzles);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Scheduler& scheduler;
|
|
||||||
ComputePassDescriptorQueue& compute_pass_descriptor_queue;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|||||||
@@ -157,9 +157,7 @@ bool ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
|
|||||||
buffer_cache.UnbindComputeStorageBuffers();
|
buffer_cache.UnbindComputeStorageBuffers();
|
||||||
size_t ssbo_index{};
|
size_t ssbo_index{};
|
||||||
for (const auto& desc : info.storage_buffers_descriptors) {
|
for (const auto& desc : info.storage_buffers_descriptors) {
|
||||||
ASSERT(desc.count == 1);
|
buffer_cache.BindComputeStorageBuffer(ssbo_index, desc.cbuf_index, desc.cbuf_offset, desc.is_written, desc.count);
|
||||||
buffer_cache.BindComputeStorageBuffer(ssbo_index, desc.cbuf_index, desc.cbuf_offset,
|
|
||||||
desc.is_written);
|
|
||||||
++ssbo_index;
|
++ssbo_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ static DescriptorBankInfo MakeBankInfo(std::span<const Shader::Info> infos) {
|
|||||||
DescriptorBankInfo bank;
|
DescriptorBankInfo bank;
|
||||||
for (const Shader::Info& info : infos) {
|
for (const Shader::Info& info : infos) {
|
||||||
bank.uniform_buffers += Accumulate(info.constant_buffer_descriptors);
|
bank.uniform_buffers += Accumulate(info.constant_buffer_descriptors);
|
||||||
bank.storage_buffers += Accumulate(info.storage_buffers_descriptors);
|
bank.storage_buffers += Accumulate(info.storage_buffers_descriptors) + static_cast<u32>(Shader::UsesStorageBufferMappings(info));
|
||||||
bank.texture_buffers += Accumulate(info.texture_buffer_descriptors);
|
bank.texture_buffers += Accumulate(info.texture_buffer_descriptors);
|
||||||
bank.image_buffers += Accumulate(info.image_buffer_descriptors);
|
bank.image_buffers += Accumulate(info.image_buffer_descriptors);
|
||||||
bank.textures += Accumulate(info.texture_descriptors);
|
bank.textures += Accumulate(info.texture_descriptors);
|
||||||
|
|||||||
@@ -367,9 +367,8 @@ bool GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|||||||
if constexpr (Spec::has_storage_buffers) {
|
if constexpr (Spec::has_storage_buffers) {
|
||||||
size_t ssbo_index{};
|
size_t ssbo_index{};
|
||||||
for (const auto& desc : info.storage_buffers_descriptors) {
|
for (const auto& desc : info.storage_buffers_descriptors) {
|
||||||
ASSERT(desc.count == 1);
|
|
||||||
buffer_cache.BindGraphicsStorageBuffer(stage, ssbo_index, desc.cbuf_index,
|
buffer_cache.BindGraphicsStorageBuffer(stage, ssbo_index, desc.cbuf_index,
|
||||||
desc.cbuf_offset, desc.is_written);
|
desc.cbuf_offset, desc.is_written, desc.count);
|
||||||
++ssbo_index;
|
++ssbo_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -694,11 +693,9 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
|||||||
const size_t num_vertex_arrays = (std::min)(
|
const size_t num_vertex_arrays = (std::min)(
|
||||||
Maxwell::NumVertexArrays, static_cast<size_t>(device.GetMaxVertexInputBindings()));
|
Maxwell::NumVertexArrays, static_cast<size_t>(device.GetMaxVertexInputBindings()));
|
||||||
for (size_t index = 0; index < num_vertex_arrays; ++index) {
|
for (size_t index = 0; index < num_vertex_arrays; ++index) {
|
||||||
const bool instanced = ((key.state.enabled_divisors >> index) & 1) != 0;
|
const bool instanced = key.state.binding_divisors[index] != 0;
|
||||||
auto rate = VK_VERTEX_INPUT_RATE_VERTEX;
|
const auto rate =
|
||||||
if (instanced) {
|
instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX;
|
||||||
rate = VK_VERTEX_INPUT_RATE_INSTANCE;
|
|
||||||
}
|
|
||||||
vertex_bindings.push_back({
|
vertex_bindings.push_back({
|
||||||
.binding = static_cast<u32>(index),
|
.binding = static_cast<u32>(index),
|
||||||
.stride = key.state.vertex_strides[index],
|
.stride = key.state.vertex_strides[index],
|
||||||
@@ -707,7 +704,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
|||||||
if (instanced) {
|
if (instanced) {
|
||||||
vertex_binding_divisors.push_back({
|
vertex_binding_divisors.push_back({
|
||||||
.binding = static_cast<u32>(index),
|
.binding = static_cast<u32>(index),
|
||||||
.divisor = device.GetVertexAttribDivisor(key.state.binding_divisors[index]),
|
.divisor = key.state.binding_divisors[index],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,13 @@ using VideoCommon::FileEnvironment;
|
|||||||
using VideoCommon::GenericEnvironment;
|
using VideoCommon::GenericEnvironment;
|
||||||
using VideoCommon::GraphicsEnvironment;
|
using VideoCommon::GraphicsEnvironment;
|
||||||
|
|
||||||
constexpr u32 CACHE_VERSION = 18;
|
// SPIR-V descriptor arrays require a fixed pipeline-layout count.
|
||||||
|
// Exploration ceiling; buffer-cache telemetry records the actual physical-range demand.
|
||||||
|
// Keep this modest because every mapped SSBO binds the full fixed array on each update.
|
||||||
|
const u32 MAX_MAPPED_STORAGE_BUFFER_DESCRIPTORS =
|
||||||
|
(std::max)(6u, static_cast<u32>(Settings::values.debug_knobs.GetValue()));
|
||||||
|
|
||||||
|
constexpr u32 CACHE_VERSION = 19;
|
||||||
constexpr size_t VULKAN_CACHE_FLUSH_PIPELINES = 128;
|
constexpr size_t VULKAN_CACHE_FLUSH_PIPELINES = 128;
|
||||||
constexpr size_t VULKAN_CACHE_FLUSH_MIN_SECONDS = 30;
|
constexpr size_t VULKAN_CACHE_FLUSH_MIN_SECONDS = 30;
|
||||||
constexpr std::array<char, 8> VULKAN_CACHE_MAGIC_NUMBER{'y', 'u', 'z', 'u', 'v', 'k', 'c', 'h'};
|
constexpr std::array<char, 8> VULKAN_CACHE_MAGIC_NUMBER{'y', 'u', 'z', 'u', 'v', 'k', 'c', 'h'};
|
||||||
@@ -432,6 +438,8 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_,
|
|||||||
device.IsUniformTexelBufferArrayNonUniformIndexingSupported(),
|
device.IsUniformTexelBufferArrayNonUniformIndexingSupported(),
|
||||||
.support_storage_texel_buffer_array_nonuniform_indexing =
|
.support_storage_texel_buffer_array_nonuniform_indexing =
|
||||||
device.IsStorageTexelBufferArrayNonUniformIndexingSupported(),
|
device.IsStorageTexelBufferArrayNonUniformIndexingSupported(),
|
||||||
|
.support_storage_buffer_array_nonuniform_indexing =
|
||||||
|
device.IsStorageBufferArrayNonUniformIndexingSupported(),
|
||||||
|
|
||||||
.warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(),
|
.warp_size_potentially_larger_than_guest = device.IsWarpSizePotentiallyBiggerThanGuest(),
|
||||||
|
|
||||||
@@ -460,6 +468,7 @@ PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_,
|
|||||||
host_info = Shader::HostTranslateInfo{
|
host_info = Shader::HostTranslateInfo{
|
||||||
.min_ssbo_alignment = device.GetStorageBufferAlignment(),
|
.min_ssbo_alignment = device.GetStorageBufferAlignment(),
|
||||||
.max_per_stage_descriptor_sampled_images = device.GetMaxPerStageDescriptorSampledImages(),
|
.max_per_stage_descriptor_sampled_images = device.GetMaxPerStageDescriptorSampledImages(),
|
||||||
|
.max_per_stage_descriptor_storage_buffers = device.GetMaxPerStageDescriptorStorageBuffers(),
|
||||||
.max_per_stage_resources = device.GetMaxPerStageResources(),
|
.max_per_stage_resources = device.GetMaxPerStageResources(),
|
||||||
.max_descriptor_set_samplers = device.GetMaxDescriptorSetSamplers(),
|
.max_descriptor_set_samplers = device.GetMaxDescriptorSetSamplers(),
|
||||||
.max_descriptor_set_uniform_buffers = device.GetMaxDescriptorSetUniformBuffers(),
|
.max_descriptor_set_uniform_buffers = device.GetMaxDescriptorSetUniformBuffers(),
|
||||||
@@ -479,6 +488,20 @@ 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(),
|
||||||
|
.storage_buffer_segment_count = [&] {
|
||||||
|
if (!device.IsStorageBufferArrayNonUniformIndexingSupported()) {
|
||||||
|
return 1U;
|
||||||
|
}
|
||||||
|
constexpr u32 MaxGraphicsStages = static_cast<u32>(Maxwell::MaxShaderStage);
|
||||||
|
const auto reserve = [](u32 limit, u32 count) {
|
||||||
|
return limit > count ? limit - count : 0U;
|
||||||
|
};
|
||||||
|
const u32 per_stage = reserve(device.GetMaxPerStageDescriptorStorageBuffers(), 1) / static_cast<u32>(Shader::Info::MAX_SSBOS);
|
||||||
|
const u32 per_set = reserve(device.GetMaxDescriptorSetStorageBuffers(), MaxGraphicsStages) / (static_cast<u32>(Shader::Info::MAX_SSBOS) * MaxGraphicsStages);
|
||||||
|
const u32 resources = reserve(device.GetMaxPerStageResources(), 1) / (static_cast<u32>(Shader::Info::MAX_SSBOS) * 2);
|
||||||
|
// ensure at least one storage buffer segment is available per stage. max is still arbitrary
|
||||||
|
return (std::max)(1U, (std::min)({MAX_MAPPED_STORAGE_BUFFER_DESCRIPTORS, per_stage, per_set, resources}));
|
||||||
|
}(),
|
||||||
};
|
};
|
||||||
host_info.ApplyDescriptorLimitPolicy();
|
host_info.ApplyDescriptorLimitPolicy();
|
||||||
|
|
||||||
|
|||||||
@@ -137,12 +137,10 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3
|
|||||||
max_y = (std::max)(max_y, 0);
|
max_y = (std::max)(max_y, 0);
|
||||||
|
|
||||||
if (src.enable) {
|
if (src.enable) {
|
||||||
const s32 min_x = static_cast<s32>(src.min_x.Value());
|
scissor.offset.x = scale_up(src.min_x);
|
||||||
const s32 max_x = static_cast<s32>(src.max_x.Value());
|
|
||||||
scissor.offset.x = scale_up(min_x);
|
|
||||||
scissor.offset.y = scale_up(min_y);
|
scissor.offset.y = scale_up(min_y);
|
||||||
scissor.extent.width = scale_up((std::max)(max_x - min_x, 0));
|
scissor.extent.width = scale_up(src.max_x - src.min_x);
|
||||||
scissor.extent.height = scale_up((std::max)(max_y - min_y, 0));
|
scissor.extent.height = scale_up(max_y - min_y);
|
||||||
} else {
|
} else {
|
||||||
scissor.offset.x = 0;
|
scissor.offset.x = 0;
|
||||||
scissor.offset.y = 0;
|
scissor.offset.y = 0;
|
||||||
@@ -262,7 +260,6 @@ void RasterizerVulkan::PrepareDraw(bool is_indexed, Func&& draw_func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) {
|
void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) {
|
||||||
buffer_cache.SetDrawInstanceCount(instance_count);
|
|
||||||
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};
|
||||||
@@ -298,7 +295,6 @@ void RasterizerVulkan::Draw(bool is_indexed, u32 instance_count) {
|
|||||||
void RasterizerVulkan::DrawIndirect() {
|
void RasterizerVulkan::DrawIndirect() {
|
||||||
const auto& params = maxwell3d->draw_manager.indirect_state;
|
const auto& params = maxwell3d->draw_manager.indirect_state;
|
||||||
buffer_cache.SetDrawIndirect(¶ms);
|
buffer_cache.SetDrawIndirect(¶ms);
|
||||||
buffer_cache.SetDrawInstanceCount(0);
|
|
||||||
PrepareDraw(params.is_indexed, [this, ¶ms] {
|
PrepareDraw(params.is_indexed, [this, ¶ms] {
|
||||||
const auto indirect_buffer = buffer_cache.GetDrawIndirectBuffer();
|
const auto indirect_buffer = buffer_cache.GetDrawIndirectBuffer();
|
||||||
const auto& buffer = indirect_buffer.first;
|
const auto& buffer = indirect_buffer.first;
|
||||||
@@ -1921,19 +1917,13 @@ void RasterizerVulkan::UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs)
|
|||||||
for (u32 binding = 0; binding < max_bindings; ++binding) {
|
for (u32 binding = 0; binding < max_bindings; ++binding) {
|
||||||
const auto& input_binding{regs.vertex_streams[binding]};
|
const auto& input_binding{regs.vertex_streams[binding]};
|
||||||
const bool is_instanced{regs.vertex_stream_instances.IsInstancingEnabled(binding)};
|
const bool is_instanced{regs.vertex_stream_instances.IsInstancingEnabled(binding)};
|
||||||
auto input_rate = VK_VERTEX_INPUT_RATE_VERTEX;
|
|
||||||
u32 divisor = 1;
|
|
||||||
if (is_instanced) {
|
|
||||||
input_rate = VK_VERTEX_INPUT_RATE_INSTANCE;
|
|
||||||
divisor = device.GetVertexAttribDivisor(input_binding.frequency);
|
|
||||||
}
|
|
||||||
bindings.push_back({
|
bindings.push_back({
|
||||||
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT,
|
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.binding = binding,
|
.binding = binding,
|
||||||
.stride = input_binding.stride,
|
.stride = input_binding.stride,
|
||||||
.inputRate = input_rate,
|
.inputRate = is_instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX,
|
||||||
.divisor = divisor,
|
.divisor = is_instanced ? input_binding.frequency : 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -449,9 +449,7 @@ void Scheduler::EndRenderPass()
|
|||||||
| VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
|
| VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
|
||||||
| VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
|
| VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
|
||||||
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
|
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
|
||||||
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
|
| VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
|
||||||
| VK_ACCESS_TRANSFER_READ_BIT
|
|
||||||
| VK_ACCESS_TRANSFER_WRITE_BIT,
|
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
@@ -462,7 +460,7 @@ void Scheduler::EndRenderPass()
|
|||||||
}
|
}
|
||||||
cmdbuf.EndRenderPass();
|
cmdbuf.EndRenderPass();
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
||||||
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, vk::PIPELINE_STAGE_GRAPHICS_COMPUTE_TRANSFER,
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, vk::PIPELINE_STAGE_GRAPHICS_COMPUTE,
|
||||||
0, nullptr, nullptr, vk::Span(barriers.data(), num_images));
|
0, nullptr, nullptr, vk::Span(barriers.data(), num_images));
|
||||||
if (has_transform_feedback) {
|
if (has_transform_feedback) {
|
||||||
static constexpr VkMemoryBarrier XFB_OUTPUT_BARRIER{
|
static constexpr VkMemoryBarrier XFB_OUTPUT_BARRIER{
|
||||||
|
|||||||
@@ -160,55 +160,6 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) {
|
|||||||
info.size.depth == 1;
|
info.size.depth == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] PixelFormat UnswizzleViewFormat(u32 bytes_per_block) {
|
|
||||||
switch (bytes_per_block) {
|
|
||||||
case 1:
|
|
||||||
return PixelFormat::R8_UINT;
|
|
||||||
case 2:
|
|
||||||
return PixelFormat::R16_UINT;
|
|
||||||
case 4:
|
|
||||||
return PixelFormat::R32_UINT;
|
|
||||||
case 8:
|
|
||||||
return PixelFormat::R32G32_UINT;
|
|
||||||
case 16:
|
|
||||||
return PixelFormat::R32G32B32A32_UINT;
|
|
||||||
default:
|
|
||||||
return PixelFormat::Invalid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr u32 UNSWIZZLE_WORKGROUP_INVOCATIONS = 32 * 32;
|
|
||||||
|
|
||||||
[[nodiscard]] bool SupportsAcceleratedUnswizzleDevice(const Device& device) {
|
|
||||||
return device.IsKhrImageFormatListSupported() &&
|
|
||||||
device.GetMaxComputeWorkGroupInvocations() >= UNSWIZZLE_WORKGROUP_INVOCATIONS;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] bool SupportsAcceleratedUnswizzle(const Device& device, const ImageInfo& info) {
|
|
||||||
if (!SupportsAcceleratedUnswizzleDevice(device)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (info.num_samples > 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (info.type != ImageType::e2D && info.type != ImageType::e3D &&
|
|
||||||
info.type != ImageType::Linear) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const PixelFormat view_format =
|
|
||||||
UnswizzleViewFormat(VideoCore::Surface::BytesPerBlock(info.format));
|
|
||||||
if (view_format == PixelFormat::Invalid) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!VideoCore::Surface::IsViewCompatible(info.format, view_format, false, true)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const auto host_format =
|
|
||||||
MaxwellToVK::SurfaceFormat(device, FormatType::Optimal, false, view_format);
|
|
||||||
return device.IsFormatSupported(host_format.format, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT,
|
|
||||||
FormatType::Optimal);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info,
|
[[nodiscard]] VkImageCreateInfo MakeImageCreateInfo(const Device& device, const ImageInfo& info,
|
||||||
std::optional<VkFormat> format_override = {}) {
|
std::optional<VkFormat> format_override = {}) {
|
||||||
auto format_info =
|
auto format_info =
|
||||||
@@ -297,18 +248,8 @@ constexpr u32 UNSWIZZLE_WORKGROUP_INVOCATIONS = 32 * 32;
|
|||||||
return allocator.CreateImage(image_ci);
|
return allocator.CreateImage(image_ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageViewType StorageViewType(ImageType type) {
|
|
||||||
if (type == ImageType::e3D) {
|
|
||||||
return VK_IMAGE_VIEW_TYPE_3D;
|
|
||||||
}
|
|
||||||
if (type == ImageType::Linear) {
|
|
||||||
return VK_IMAGE_VIEW_TYPE_2D;
|
|
||||||
}
|
|
||||||
return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] vk::ImageView MakeStorageView(const vk::Device& device, u32 level, VkImage image,
|
[[nodiscard]] vk::ImageView MakeStorageView(const vk::Device& device, u32 level, VkImage image,
|
||||||
VkFormat format, VkImageViewType view_type) {
|
VkFormat format) {
|
||||||
static constexpr VkImageViewUsageCreateInfo storage_image_view_usage_create_info{
|
static constexpr VkImageViewUsageCreateInfo storage_image_view_usage_create_info{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
@@ -319,7 +260,7 @@ constexpr u32 UNSWIZZLE_WORKGROUP_INVOCATIONS = 32 * 32;
|
|||||||
.pNext = &storage_image_view_usage_create_info,
|
.pNext = &storage_image_view_usage_create_info,
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.image = image,
|
.image = image,
|
||||||
.viewType = view_type,
|
.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
||||||
.format = format,
|
.format = format,
|
||||||
.components{
|
.components{
|
||||||
.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
.r = VK_COMPONENT_SWIZZLE_IDENTITY,
|
||||||
@@ -717,11 +658,18 @@ void CopyBufferToImage(vk::CommandBuffer cmdbuf, VkBuffer src_buffer, VkImage im
|
|||||||
.subresourceRange = subresource_range,
|
.subresourceRange = subresource_range,
|
||||||
};
|
};
|
||||||
|
|
||||||
cmdbuf.PipelineBarrier(vk::PIPELINE_STAGE_GRAPHICS_COMPUTE, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT |
|
||||||
|
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
|
||||||
read_barrier);
|
read_barrier);
|
||||||
cmdbuf.CopyBufferToImage(src_buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, copies);
|
cmdbuf.CopyBufferToImage(src_buffer, image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, copies);
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, vk::PIPELINE_STAGE_GRAPHICS_COMPUTE, 0,
|
// TODO: Move this to another API
|
||||||
nullptr, nullptr, write_barrier);
|
cmdbuf.PipelineBarrier(
|
||||||
|
VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT |
|
||||||
|
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT |
|
||||||
|
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
|
||||||
|
0, nullptr, nullptr, write_barrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageBlit MakeImageBlit(const Region2D& dst_region, const Region2D& src_region,
|
[[nodiscard]] VkImageBlit MakeImageBlit(const Region2D& dst_region, const Region2D& src_region,
|
||||||
@@ -1020,14 +968,6 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, Scheduler& sched
|
|||||||
bl3d_unswizzle_pass.emplace(device, scheduler, descriptor_pool,
|
bl3d_unswizzle_pass.emplace(device, scheduler, descriptor_pool,
|
||||||
staging_buffer_pool, compute_pass_descriptor_queue);
|
staging_buffer_pool, compute_pass_descriptor_queue);
|
||||||
}
|
}
|
||||||
if (SupportsAcceleratedUnswizzleDevice(device)) {
|
|
||||||
bl_unswizzle_2d_pass.emplace(device, scheduler, descriptor_pool,
|
|
||||||
compute_pass_descriptor_queue);
|
|
||||||
bl_unswizzle_image_3d_pass.emplace(device, scheduler, descriptor_pool,
|
|
||||||
compute_pass_descriptor_queue);
|
|
||||||
pitch_unswizzle_pass.emplace(device, scheduler, descriptor_pool,
|
|
||||||
compute_pass_descriptor_queue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheRuntime::Finish() {
|
void TextureCacheRuntime::Finish() {
|
||||||
@@ -1962,12 +1902,16 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
|
|||||||
if (runtime->device.HasDebuggingToolAttached()) {
|
if (runtime->device.HasDebuggingToolAttached()) {
|
||||||
original_image.SetObjectNameEXT(VideoCommon::Name(*this).c_str());
|
original_image.SetObjectNameEXT(VideoCommon::Name(*this).c_str());
|
||||||
}
|
}
|
||||||
if (False(flags & VideoCommon::ImageFlagBits::Converted) &&
|
|
||||||
SupportsAcceleratedUnswizzle(runtime->device, info)) {
|
|
||||||
flags |= VideoCommon::ImageFlagBits::AcceleratedUpload;
|
|
||||||
}
|
|
||||||
current_image = &Image::original_image;
|
current_image = &Image::original_image;
|
||||||
storage_image_views.resize(info.resources.levels);
|
storage_image_views.resize(info.resources.levels);
|
||||||
|
if (WillUseAcceleratedAstcDecode(runtime->device, info)) {
|
||||||
|
const auto& device = runtime->device.GetLogical();
|
||||||
|
const VkFormat storage_format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
|
||||||
|
for (s32 level = 0; level < info.resources.levels; ++level) {
|
||||||
|
storage_image_views[level] =
|
||||||
|
MakeStorageView(device, level, *original_image, storage_format);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBase{params} {}
|
Image::Image(const VideoCommon::NullImageParams& params) : VideoCommon::ImageBase{params} {}
|
||||||
@@ -2091,7 +2035,7 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset,
|
|||||||
temp_vk_image, info.format, info.num_samples,
|
temp_vk_image, info.format, info.num_samples,
|
||||||
{image_copies.data(), image_copies.size()}, false);
|
{image_copies.data(), image_copies.size()}, false);
|
||||||
}
|
}
|
||||||
InitializationFor(current_image) = true;
|
initialized = true;
|
||||||
runtime->ReleaseMsaaScratchImage(temp_vk_image);
|
runtime->ReleaseMsaaScratchImage(temp_vk_image);
|
||||||
|
|
||||||
if (is_rescaled) {
|
if (is_rescaled) {
|
||||||
@@ -2112,7 +2056,7 @@ void Image::UploadMemory(VkBuffer buffer, VkDeviceSize offset,
|
|||||||
const VkBuffer src_buffer = buffer;
|
const VkBuffer src_buffer = buffer;
|
||||||
const VkImage vk_image = *original_image;
|
const VkImage vk_image = *original_image;
|
||||||
const VkImageAspectFlags vk_aspect_mask = aspect_mask;
|
const VkImageAspectFlags vk_aspect_mask = aspect_mask;
|
||||||
const bool was_initialized = std::exchange(InitializationFor(&Image::original_image), true);
|
const bool was_initialized = std::exchange(initialized, true);
|
||||||
|
|
||||||
scheduler->Record([src_buffer, vk_image, vk_aspect_mask, was_initialized,
|
scheduler->Record([src_buffer, vk_image, vk_aspect_mask, was_initialized,
|
||||||
vk_copies](vk::CommandBuffer cmdbuf) {
|
vk_copies](vk::CommandBuffer cmdbuf) {
|
||||||
@@ -2377,46 +2321,16 @@ void Image::DownloadMemory(const StagingBufferRef& map, std::span<const BufferIm
|
|||||||
DownloadMemory(buffers, offsets, copies);
|
DownloadMemory(buffers, offsets, copies);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<vk::ImageView>& Image::StorageViewsFor(vk::Image Image::*image) {
|
|
||||||
if (image == &Image::scaled_image) {
|
|
||||||
if (scaled_storage_image_views.empty()) {
|
|
||||||
scaled_storage_image_views.resize(info.resources.levels);
|
|
||||||
}
|
|
||||||
return scaled_storage_image_views;
|
|
||||||
}
|
|
||||||
return storage_image_views;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool& Image::InitializationFor(vk::Image Image::*image) noexcept {
|
|
||||||
if (image == &Image::scaled_image) {
|
|
||||||
return scaled_initialized;
|
|
||||||
}
|
|
||||||
return original_initialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkImageView Image::StorageImageView(s32 level) noexcept {
|
VkImageView Image::StorageImageView(s32 level) noexcept {
|
||||||
const bool astc_decode = WillUseAcceleratedAstcDecode(runtime->device, info);
|
auto& view = storage_image_views[level];
|
||||||
const bool unswizzle_upload =
|
|
||||||
!astc_decode && True(flags & ImageFlagBits::AcceleratedUpload);
|
|
||||||
vk::Image Image::*target = current_image;
|
|
||||||
if (astc_decode || unswizzle_upload) {
|
|
||||||
target = &Image::original_image;
|
|
||||||
}
|
|
||||||
auto& view = StorageViewsFor(target)[level];
|
|
||||||
if (!view) {
|
if (!view) {
|
||||||
auto format_info =
|
auto format_info =
|
||||||
MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format);
|
MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format);
|
||||||
if (astc_decode) {
|
if (WillUseAcceleratedAstcDecode(runtime->device, info)) {
|
||||||
format_info.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
|
format_info.format = VK_FORMAT_A8B8G8R8_UNORM_PACK32;
|
||||||
}
|
}
|
||||||
if (unswizzle_upload) {
|
view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*current_image),
|
||||||
const PixelFormat view_format =
|
format_info.format);
|
||||||
UnswizzleViewFormat(VideoCore::Surface::BytesPerBlock(info.format));
|
|
||||||
format_info = MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, false,
|
|
||||||
view_format);
|
|
||||||
}
|
|
||||||
view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*target),
|
|
||||||
format_info.format, StorageViewType(info.type));
|
|
||||||
}
|
}
|
||||||
return *view;
|
return *view;
|
||||||
}
|
}
|
||||||
@@ -2456,7 +2370,6 @@ bool Image::ScaleUp(bool ignore) {
|
|||||||
}
|
}
|
||||||
if (NeedsScaleHelper()) {
|
if (NeedsScaleHelper()) {
|
||||||
if (!BlitScaleHelper(true)) {
|
if (!BlitScaleHelper(true)) {
|
||||||
flags &= ~ImageFlagBits::Rescaled;
|
|
||||||
current_image = &Image::original_image;
|
current_image = &Image::original_image;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2646,10 +2559,6 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
|||||||
if (device->IsExtAstcDecodeModeSupported() && IsLdrAstcFormat(format_info.format)) {
|
if (device->IsExtAstcDecodeModeSupported() && IsLdrAstcFormat(format_info.format)) {
|
||||||
view_next = &astc_decode_mode;
|
view_next = &astc_decode_mode;
|
||||||
}
|
}
|
||||||
auto subresource_range = MakeSubresourceRange(aspect_mask, info.range);
|
|
||||||
if (True(flags & VideoCommon::ImageViewFlagBits::Slice)) {
|
|
||||||
subresource_range.levelCount = 1;
|
|
||||||
}
|
|
||||||
const VkImageViewCreateInfo create_info{
|
const VkImageViewCreateInfo create_info{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
.pNext = view_next,
|
.pNext = view_next,
|
||||||
@@ -2658,7 +2567,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
|||||||
.viewType = VkImageViewType{},
|
.viewType = VkImageViewType{},
|
||||||
.format = format_info.format,
|
.format = format_info.format,
|
||||||
.components = swizzle_mapping,
|
.components = swizzle_mapping,
|
||||||
.subresourceRange = subresource_range,
|
.subresourceRange = MakeSubresourceRange(aspect_mask, info.range),
|
||||||
};
|
};
|
||||||
const auto create = [&](TextureType tex_type, std::optional<u32> num_layers) {
|
const auto create = [&](TextureType tex_type, std::optional<u32> num_layers) {
|
||||||
VkImageViewCreateInfo ci{create_info};
|
VkImageViewCreateInfo ci{create_info};
|
||||||
@@ -3232,19 +3141,6 @@ void TextureCacheRuntime::AccelerateImageUpload(
|
|||||||
return astc_decoder_pass->Assemble(image, map, swizzles);
|
return astc_decoder_pass->Assemble(image, map, swizzles);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bl_unswizzle_2d_pass && image.info.type == ImageType::e2D) {
|
|
||||||
return bl_unswizzle_2d_pass->Unswizzle(image, map, swizzles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bl_unswizzle_image_3d_pass && image.info.type == ImageType::e3D &&
|
|
||||||
!IsPixelFormatBCn(image.info.format)) {
|
|
||||||
return bl_unswizzle_image_3d_pass->Unswizzle(image, map, swizzles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pitch_unswizzle_pass && image.info.type == ImageType::Linear) {
|
|
||||||
return pitch_unswizzle_pass->Unswizzle(image, map, swizzles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Settings::values.gpu_unswizzle_enabled.GetValue() || !bl3d_unswizzle_pass) {
|
if (!Settings::values.gpu_unswizzle_enabled.GetValue() || !bl3d_unswizzle_pass) {
|
||||||
if (IsPixelFormatBCn(image.info.format) && image.info.type == ImageType::e3D) {
|
if (IsPixelFormatBCn(image.info.format) && image.info.type == ImageType::e3D) {
|
||||||
ASSERT(false && "GPU unswizzle is disabled for BCn 3D texture");
|
ASSERT(false && "GPU unswizzle is disabled for BCn 3D texture");
|
||||||
|
|||||||
@@ -159,9 +159,6 @@ public:
|
|||||||
std::optional<ASTCDecoderPass> astc_decoder_pass;
|
std::optional<ASTCDecoderPass> astc_decoder_pass;
|
||||||
|
|
||||||
std::optional<BlockLinearUnswizzle3DPass> bl3d_unswizzle_pass;
|
std::optional<BlockLinearUnswizzle3DPass> bl3d_unswizzle_pass;
|
||||||
std::optional<BlockLinearUnswizzle2DPass> bl_unswizzle_2d_pass;
|
|
||||||
std::optional<BlockLinearUnswizzleImage3DPass> bl_unswizzle_image_3d_pass;
|
|
||||||
std::optional<PitchUnswizzlePass> pitch_unswizzle_pass;
|
|
||||||
const Settings::ResolutionScalingInfo& resolution;
|
const Settings::ResolutionScalingInfo& resolution;
|
||||||
std::array<std::vector<VkFormat>, VideoCore::Surface::MaxPixelFormat> view_formats;
|
std::array<std::vector<VkFormat>, VideoCore::Surface::MaxPixelFormat> view_formats;
|
||||||
|
|
||||||
@@ -353,7 +350,7 @@ public:
|
|||||||
|
|
||||||
/// Returns true when the image is already initialized and mark it as initialized
|
/// Returns true when the image is already initialized and mark it as initialized
|
||||||
[[nodiscard]] bool ExchangeInitialization() noexcept {
|
[[nodiscard]] bool ExchangeInitialization() noexcept {
|
||||||
return std::exchange(InitializationFor(current_image), true);
|
return std::exchange(initialized, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
VkImageView StorageImageView(s32 level) noexcept;
|
VkImageView StorageImageView(s32 level) noexcept;
|
||||||
@@ -373,10 +370,6 @@ private:
|
|||||||
|
|
||||||
bool NeedsScaleHelper() const;
|
bool NeedsScaleHelper() const;
|
||||||
|
|
||||||
std::vector<vk::ImageView>& StorageViewsFor(vk::Image Image::*image);
|
|
||||||
|
|
||||||
bool& InitializationFor(vk::Image Image::*image) noexcept;
|
|
||||||
|
|
||||||
Scheduler* scheduler{};
|
Scheduler* scheduler{};
|
||||||
TextureCacheRuntime* runtime{};
|
TextureCacheRuntime* runtime{};
|
||||||
|
|
||||||
@@ -394,10 +387,8 @@ private:
|
|||||||
vk::Image Image::*current_image{};
|
vk::Image Image::*current_image{};
|
||||||
|
|
||||||
std::vector<vk::ImageView> storage_image_views;
|
std::vector<vk::ImageView> storage_image_views;
|
||||||
std::vector<vk::ImageView> scaled_storage_image_views;
|
|
||||||
VkImageAspectFlags aspect_mask = 0;
|
VkImageAspectFlags aspect_mask = 0;
|
||||||
bool original_initialized = false;
|
bool initialized = false;
|
||||||
bool scaled_initialized = false;
|
|
||||||
|
|
||||||
std::optional<Framebuffer> scale_framebuffer;
|
std::optional<Framebuffer> scale_framebuffer;
|
||||||
std::optional<Framebuffer> normal_framebuffer;
|
std::optional<Framebuffer> normal_framebuffer;
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
@@ -26,8 +23,8 @@ struct BlockLinearSwizzle2DParams {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct BlockLinearSwizzle3DParams {
|
struct BlockLinearSwizzle3DParams {
|
||||||
alignas(16) std::array<u32, 3> origin;
|
std::array<u32, 3> origin;
|
||||||
alignas(16) std::array<s32, 3> destination;
|
std::array<s32, 3> destination;
|
||||||
u32 bytes_per_block_log2;
|
u32 bytes_per_block_log2;
|
||||||
u32 slice_size;
|
u32 slice_size;
|
||||||
u32 block_size;
|
u32 block_size;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "video_core/engines/kepler_compute.h"
|
#include "video_core/engines/kepler_compute.h"
|
||||||
#include "video_core/guest_memory.h"
|
#include "video_core/guest_memory.h"
|
||||||
#include "video_core/host1x/gpu_device_memory_manager.h"
|
#include "video_core/host1x/gpu_device_memory_manager.h"
|
||||||
#include "video_core/texture_cache/accelerated_swizzle.h"
|
|
||||||
#include "video_core/texture_cache/image_view_base.h"
|
#include "video_core/texture_cache/image_view_base.h"
|
||||||
#include "video_core/texture_cache/samples_helper.h"
|
#include "video_core/texture_cache/samples_helper.h"
|
||||||
#include "video_core/texture_cache/texture_cache_base.h"
|
#include "video_core/texture_cache/texture_cache_base.h"
|
||||||
@@ -280,11 +279,11 @@ void TextureCache<P>::CheckFeedbackLoop(std::span<const ImageViewInOut> views) {
|
|||||||
|
|
||||||
const ImageId view_image_id = slot_image_views[view.id].image_id;
|
const ImageId view_image_id = slot_image_views[view.id].image_id;
|
||||||
{
|
{
|
||||||
bool is_feedback = false;
|
bool is_continue = false;
|
||||||
for (size_t i = 0; i < 8; ++i)
|
for (size_t i = 0; i < 8; ++i)
|
||||||
is_feedback |= (rt_active_mask & (1u << i)) && view_image_id == rt_image_id[i];
|
is_continue |= (rt_active_mask & (1u << i)) && view_image_id == rt_image_id[i];
|
||||||
if (is_feedback)
|
if (is_continue)
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
if (depth_active && view_image_id == rt_depth_image_id) {
|
if (depth_active && view_image_id == rt_depth_image_id) {
|
||||||
return true;
|
return true;
|
||||||
@@ -627,25 +626,14 @@ void TextureCache<P>::DownloadMemory(DAddr cpu_addr, size_t size) {
|
|||||||
std::ranges::sort(images, [this](ImageId lhs, ImageId rhs) {
|
std::ranges::sort(images, [this](ImageId lhs, ImageId rhs) {
|
||||||
return slot_images[lhs].modification_tick < slot_images[rhs].modification_tick;
|
return slot_images[lhs].modification_tick < slot_images[rhs].modification_tick;
|
||||||
});
|
});
|
||||||
size_t total_size_bytes = 0;
|
|
||||||
for (const ImageId image_id : images) {
|
|
||||||
total_size_bytes += slot_images[image_id].unswizzled_size_bytes;
|
|
||||||
}
|
|
||||||
auto download_map = runtime.DownloadStagingBuffer(total_size_bytes);
|
|
||||||
for (const ImageId image_id : images) {
|
for (const ImageId image_id : images) {
|
||||||
Image& image = slot_images[image_id];
|
Image& image = slot_images[image_id];
|
||||||
|
auto map = runtime.DownloadStagingBuffer(image.unswizzled_size_bytes);
|
||||||
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
||||||
image.DownloadMemory(download_map, copies);
|
image.DownloadMemory(map, copies);
|
||||||
download_map.offset += image.unswizzled_size_bytes;
|
runtime.Finish();
|
||||||
}
|
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span,
|
||||||
runtime.Finish();
|
|
||||||
std::span<u8> download_span = download_map.mapped_span;
|
|
||||||
for (const ImageId image_id : images) {
|
|
||||||
const ImageBase& image = slot_images[image_id];
|
|
||||||
const auto copies = FixSmallVectorADL(FullDownloadCopies(image.info));
|
|
||||||
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span,
|
|
||||||
swizzle_data_buffer);
|
swizzle_data_buffer);
|
||||||
download_span = download_span.subspan(image.unswizzled_size_bytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1134,12 +1122,6 @@ void TextureCache<P>::RefreshContents(Image& image, ImageId image_id) {
|
|||||||
|
|
||||||
TrackImage(image, image_id);
|
TrackImage(image, image_id);
|
||||||
|
|
||||||
if (image.info.rescaleable &&
|
|
||||||
IsRegionGpuModified(image.cpu_addr, image.guest_size_bytes)) {
|
|
||||||
runtime.TransitionImageLayout(image);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (image.info.num_samples > 1 && !runtime.CanUploadMSAA()) {
|
if (image.info.num_samples > 1 && !runtime.CanUploadMSAA()) {
|
||||||
LOG_WARNING(HW_GPU, "MSAA image uploads are not implemented");
|
LOG_WARNING(HW_GPU, "MSAA image uploads are not implemented");
|
||||||
runtime.TransitionImageLayout(image);
|
runtime.TransitionImageLayout(image);
|
||||||
@@ -1175,7 +1157,8 @@ void TextureCache<P>::UploadImageContents(Image& image, StagingBuffer& staging)
|
|||||||
const GPUVAddr gpu_addr = image.gpu_addr;
|
const GPUVAddr gpu_addr = image.gpu_addr;
|
||||||
|
|
||||||
if (True(image.flags & ImageFlagBits::AcceleratedUpload)) {
|
if (True(image.flags & ImageFlagBits::AcceleratedUpload)) {
|
||||||
gpu_memory->ReadBlockUnsafe(gpu_addr, mapped_span.data(), image.guest_size_bytes);
|
gpu_memory->ReadBlock(gpu_addr, mapped_span.data(), mapped_span.size_bytes(),
|
||||||
|
VideoCommon::CacheType::NoTextureCache);
|
||||||
const auto uploads = FullUploadSwizzles(image.info);
|
const auto uploads = FullUploadSwizzles(image.info);
|
||||||
runtime.AccelerateImageUpload(image, staging, FixSmallVectorADL(uploads), 0, 0);
|
runtime.AccelerateImageUpload(image, staging, FixSmallVectorADL(uploads), 0, 0);
|
||||||
return;
|
return;
|
||||||
@@ -1282,9 +1265,6 @@ ImageId TextureCache<P>::FindImage(const ImageInfo& info, GPUVAddr gpu_addr,
|
|||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
bool TextureCache<P>::ImageCanRescale(ImageBase& image) {
|
bool TextureCache<P>::ImageCanRescale(ImageBase& image) {
|
||||||
if (!Settings::values.resolution_info.active) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!image.info.rescaleable) {
|
if (!image.info.rescaleable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1372,12 +1352,12 @@ void TextureCache<P>::QueueAsyncDecode(Image& image, ImageId image_id) {
|
|||||||
decode->image_id = image_id;
|
decode->image_id = image_id;
|
||||||
async_decodes.push_back(std::move(decode));
|
async_decodes.push_back(std::move(decode));
|
||||||
|
|
||||||
Common::ScratchBuffer<u8> local_unswizzle_data_buffer(image.unswizzled_size_bytes);
|
std::vector<u8> local_unswizzle_data_buffer(image.unswizzled_size_bytes, 0);
|
||||||
Tegra::Memory::GpuGuestMemory<u8, Tegra::Memory::GuestMemoryFlags::UnsafeRead> swizzle_data(*gpu_memory, image.gpu_addr, image.guest_size_bytes, &swizzle_data_buffer);
|
Tegra::Memory::GpuGuestMemory<u8, Tegra::Memory::GuestMemoryFlags::UnsafeRead> swizzle_data(*gpu_memory, image.gpu_addr, image.guest_size_bytes, &swizzle_data_buffer);
|
||||||
auto copies = UnswizzleImage(*gpu_memory, image.gpu_addr, image.info, swizzle_data, local_unswizzle_data_buffer);
|
auto copies = UnswizzleImage(*gpu_memory, image.gpu_addr, image.info, swizzle_data, local_unswizzle_data_buffer);
|
||||||
const size_t out_size = MapSizeBytes(image);
|
const size_t out_size = MapSizeBytes(image);
|
||||||
|
|
||||||
auto func = [out_size, copies = std::move(copies), info = image.info,
|
auto func = [out_size, copies, info = image.info,
|
||||||
input = std::move(local_unswizzle_data_buffer),
|
input = std::move(local_unswizzle_data_buffer),
|
||||||
async_decode = decode_ptr]() mutable {
|
async_decode = decode_ptr]() mutable {
|
||||||
async_decode->decoded_data.resize_destructive(out_size);
|
async_decode->decoded_data.resize_destructive(out_size);
|
||||||
@@ -1446,16 +1426,18 @@ void TextureCache<P>::TickAsyncUnswizzle() {
|
|||||||
Image& image = slot_images[task.image_id];
|
Image& image = slot_images[task.image_id];
|
||||||
|
|
||||||
if (!task.initialized) {
|
if (!task.initialized) {
|
||||||
task.total_size = image.guest_size_bytes;
|
task.total_size = MapSizeBytes(image);
|
||||||
task.staging_buffer = runtime.UploadStagingBuffer(task.total_size, true);
|
task.staging_buffer = runtime.UploadStagingBuffer(task.total_size, true);
|
||||||
|
|
||||||
const auto layout = FullUploadSwizzles(task.info);
|
const auto& info = image.info;
|
||||||
const auto params =
|
const u32 bytes_per_block = BytesPerBlock(info.format);
|
||||||
VideoCommon::Accelerated::MakeBlockLinearSwizzle3DParams(layout.front(), task.info);
|
const u32 width_blocks = Common::DivCeil(info.size.width, 4u);
|
||||||
task.bytes_per_slice = params.slice_size;
|
const u32 height_blocks = Common::DivCeil(info.size.height, 4u);
|
||||||
task.chunked = task.info.block.depth == 0;
|
|
||||||
|
const u32 stride = width_blocks * bytes_per_block;
|
||||||
|
const u32 aligned_height = height_blocks;
|
||||||
|
task.bytes_per_slice = static_cast<size_t>(stride) * aligned_height;
|
||||||
task.last_submitted_offset = 0;
|
task.last_submitted_offset = 0;
|
||||||
task.slices_submitted = 0;
|
|
||||||
task.initialized = true;
|
task.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1470,39 +1452,31 @@ void TextureCache<P>::TickAsyncUnswizzle() {
|
|||||||
if (copy_amount == 0) copy_amount = task.bytes_per_slice;
|
if (copy_amount == 0) copy_amount = task.bytes_per_slice;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu_memory->ReadBlockUnsafe(image.gpu_addr + task.current_offset,
|
gpu_memory->ReadBlock(image.gpu_addr + task.current_offset,
|
||||||
task.staging_buffer.mapped_span.data() + task.current_offset,
|
task.staging_buffer.mapped_span.data() + task.current_offset,
|
||||||
copy_amount);
|
copy_amount);
|
||||||
task.current_offset += copy_amount;
|
task.current_offset += copy_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool is_final_batch = task.current_offset >= task.total_size;
|
const bool is_final_batch = task.current_offset >= task.total_size;
|
||||||
|
const size_t bytes_ready = task.current_offset - task.last_submitted_offset;
|
||||||
|
const u32 complete_slices = static_cast<u32>(bytes_ready / task.bytes_per_slice);
|
||||||
|
|
||||||
if (task.chunked) {
|
if (complete_slices >= swizzle_slices_per_batch || (is_final_batch && complete_slices > 0)) {
|
||||||
const size_t bytes_ready = task.current_offset - task.last_submitted_offset;
|
const u32 z_start = static_cast<u32>(task.last_submitted_offset / task.bytes_per_slice);
|
||||||
const u32 complete_slices = static_cast<u32>(bytes_ready / task.bytes_per_slice);
|
const u32 slices_to_process = (std::min)(complete_slices, swizzle_slices_per_batch);
|
||||||
|
const u32 z_count = (std::min)(slices_to_process, image.info.size.depth - z_start);
|
||||||
|
|
||||||
if (complete_slices >= swizzle_slices_per_batch || (is_final_batch && complete_slices > 0)) {
|
if (z_count > 0) {
|
||||||
const u32 z_start = task.slices_submitted;
|
const auto uploads = FullUploadSwizzles(task.info);
|
||||||
const u32 slices_to_process = (std::min)(complete_slices, swizzle_slices_per_batch);
|
runtime.AccelerateImageUpload(image, task.staging_buffer, FixSmallVectorADL(uploads), z_start, z_count);
|
||||||
const u32 z_count = (std::min)(slices_to_process, image.info.size.depth - z_start);
|
task.last_submitted_offset += (static_cast<size_t>(z_count) * task.bytes_per_slice);
|
||||||
|
|
||||||
if (z_count > 0) {
|
|
||||||
const auto uploads = FullUploadSwizzles(task.info);
|
|
||||||
runtime.AccelerateImageUpload(image, task.staging_buffer,
|
|
||||||
FixSmallVectorADL(uploads), z_start, z_count);
|
|
||||||
task.last_submitted_offset += static_cast<size_t>(z_count) * task.bytes_per_slice;
|
|
||||||
task.slices_submitted += z_count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (is_final_batch && task.slices_submitted == 0) {
|
|
||||||
const auto uploads = FullUploadSwizzles(task.info);
|
|
||||||
runtime.AccelerateImageUpload(image, task.staging_buffer, FixSmallVectorADL(uploads), 0,
|
|
||||||
image.info.size.depth);
|
|
||||||
task.slices_submitted = image.info.size.depth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool all_slices_submitted = task.slices_submitted >= image.info.size.depth;
|
// Check if complete
|
||||||
|
const u32 slices_submitted = static_cast<u32>(task.last_submitted_offset / task.bytes_per_slice);
|
||||||
|
const bool all_slices_submitted = slices_submitted >= image.info.size.depth;
|
||||||
|
|
||||||
if (is_final_batch && all_slices_submitted) {
|
if (is_final_batch && all_slices_submitted) {
|
||||||
runtime.FreeDeferredStagingBuffer(task.staging_buffer);
|
runtime.FreeDeferredStagingBuffer(task.staging_buffer);
|
||||||
|
|||||||
@@ -139,8 +139,6 @@ class TextureCache : public VideoCommon::ChannelSetupCaches<TextureCacheChannelI
|
|||||||
AsyncBuffer staging_buffer;
|
AsyncBuffer staging_buffer;
|
||||||
size_t last_submitted_offset = 0;
|
size_t last_submitted_offset = 0;
|
||||||
size_t bytes_per_slice;
|
size_t bytes_per_slice;
|
||||||
u32 slices_submitted = 0;
|
|
||||||
bool chunked = false;
|
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -708,7 +708,6 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR
|
|||||||
descriptor_indexing.shaderUniformTexelBufferArrayDynamicIndexing = false;
|
descriptor_indexing.shaderUniformTexelBufferArrayDynamicIndexing = false;
|
||||||
descriptor_indexing.shaderStorageTexelBufferArrayDynamicIndexing = false;
|
descriptor_indexing.shaderStorageTexelBufferArrayDynamicIndexing = false;
|
||||||
descriptor_indexing.shaderUniformBufferArrayNonUniformIndexing = false;
|
descriptor_indexing.shaderUniformBufferArrayNonUniformIndexing = false;
|
||||||
descriptor_indexing.shaderStorageBufferArrayNonUniformIndexing = false;
|
|
||||||
descriptor_indexing.shaderInputAttachmentArrayNonUniformIndexing = false;
|
descriptor_indexing.shaderInputAttachmentArrayNonUniformIndexing = false;
|
||||||
descriptor_indexing.descriptorBindingUniformBufferUpdateAfterBind = false;
|
descriptor_indexing.descriptorBindingUniformBufferUpdateAfterBind = false;
|
||||||
descriptor_indexing.descriptorBindingSampledImageUpdateAfterBind = false;
|
descriptor_indexing.descriptorBindingSampledImageUpdateAfterBind = false;
|
||||||
@@ -1219,11 +1218,6 @@ bool Device::GetSuitability(bool requires_swapchain) {
|
|||||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
|
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
|
||||||
SetNext(next, properties.transform_feedback);
|
SetNext(next, properties.transform_feedback);
|
||||||
}
|
}
|
||||||
if (extensions.vertex_attribute_divisor) {
|
|
||||||
properties.vertex_attribute_divisor.sType =
|
|
||||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT;
|
|
||||||
SetNext(next, properties.vertex_attribute_divisor);
|
|
||||||
}
|
|
||||||
if (extensions.maintenance5) {
|
if (extensions.maintenance5) {
|
||||||
properties.maintenance5.sType =
|
properties.maintenance5.sType =
|
||||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR;
|
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR;
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
|||||||
FEATURE(EXT, ProvokingVertex, PROVOKING_VERTEX, provoking_vertex) \
|
FEATURE(EXT, ProvokingVertex, PROVOKING_VERTEX, provoking_vertex) \
|
||||||
FEATURE(EXT, Robustness2, ROBUSTNESS_2, robustness2) \
|
FEATURE(EXT, Robustness2, ROBUSTNESS_2, robustness2) \
|
||||||
FEATURE(EXT, TransformFeedback, TRANSFORM_FEEDBACK, transform_feedback) \
|
FEATURE(EXT, TransformFeedback, TRANSFORM_FEEDBACK, transform_feedback) \
|
||||||
FEATURE(EXT, VertexAttributeDivisor, VERTEX_ATTRIBUTE_DIVISOR, vertex_attribute_divisor) \
|
|
||||||
FEATURE(EXT, VertexInputDynamicState, VERTEX_INPUT_DYNAMIC_STATE, vertex_input_dynamic_state) \
|
FEATURE(EXT, VertexInputDynamicState, VERTEX_INPUT_DYNAMIC_STATE, vertex_input_dynamic_state) \
|
||||||
FEATURE(KHR, Maintenance5, MAINTENANCE_5, maintenance5) \
|
FEATURE(KHR, Maintenance5, MAINTENANCE_5, maintenance5) \
|
||||||
FEATURE(KHR, Maintenance6, MAINTENANCE_6, maintenance6) \
|
FEATURE(KHR, Maintenance6, MAINTENANCE_6, maintenance6) \
|
||||||
@@ -93,6 +92,7 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
|||||||
EXTENSION(EXT, SHADER_STENCIL_EXPORT, shader_stencil_export) \
|
EXTENSION(EXT, SHADER_STENCIL_EXPORT, shader_stencil_export) \
|
||||||
EXTENSION(EXT, SHADER_VIEWPORT_INDEX_LAYER, shader_viewport_index_layer) \
|
EXTENSION(EXT, SHADER_VIEWPORT_INDEX_LAYER, shader_viewport_index_layer) \
|
||||||
EXTENSION(EXT, TOOLING_INFO, tooling_info) \
|
EXTENSION(EXT, TOOLING_INFO, tooling_info) \
|
||||||
|
EXTENSION(EXT, VERTEX_ATTRIBUTE_DIVISOR, vertex_attribute_divisor) \
|
||||||
EXTENSION(KHR, CREATE_RENDERPASS_2, create_renderpass2) \
|
EXTENSION(KHR, CREATE_RENDERPASS_2, create_renderpass2) \
|
||||||
EXTENSION(KHR, DEPTH_STENCIL_RESOLVE, depth_stencil_resolve) \
|
EXTENSION(KHR, DEPTH_STENCIL_RESOLVE, depth_stencil_resolve) \
|
||||||
EXTENSION(KHR, DRAW_INDIRECT_COUNT, draw_indirect_count) \
|
EXTENSION(KHR, DRAW_INDIRECT_COUNT, draw_indirect_count) \
|
||||||
@@ -359,8 +359,8 @@ public:
|
|||||||
|
|
||||||
#define FN_MAX_LIMIT_LIST \
|
#define FN_MAX_LIMIT_LIST \
|
||||||
FN_MAX_LIMIT_ELEM(ComputeSharedMemorySize) \
|
FN_MAX_LIMIT_ELEM(ComputeSharedMemorySize) \
|
||||||
FN_MAX_LIMIT_ELEM(ComputeWorkGroupInvocations) \
|
|
||||||
FN_MAX_LIMIT_ELEM(PerStageDescriptorSampledImages) \
|
FN_MAX_LIMIT_ELEM(PerStageDescriptorSampledImages) \
|
||||||
|
FN_MAX_LIMIT_ELEM(PerStageDescriptorStorageBuffers) \
|
||||||
FN_MAX_LIMIT_ELEM(PerStageResources) \
|
FN_MAX_LIMIT_ELEM(PerStageResources) \
|
||||||
FN_MAX_LIMIT_ELEM(DescriptorSetSamplers) \
|
FN_MAX_LIMIT_ELEM(DescriptorSetSamplers) \
|
||||||
FN_MAX_LIMIT_ELEM(DescriptorSetUniformBuffers) \
|
FN_MAX_LIMIT_ELEM(DescriptorSetUniformBuffers) \
|
||||||
@@ -416,6 +416,10 @@ FN_MAX_LIMIT_LIST
|
|||||||
return features.descriptor_indexing.shaderStorageTexelBufferArrayNonUniformIndexing;
|
return features.descriptor_indexing.shaderStorageTexelBufferArrayNonUniformIndexing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsStorageBufferArrayNonUniformIndexingSupported() const {
|
||||||
|
return features.descriptor_indexing.shaderStorageBufferArrayNonUniformIndexing;
|
||||||
|
}
|
||||||
|
|
||||||
/// 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;
|
||||||
@@ -690,32 +694,6 @@ FN_MAX_LIMIT_LIST
|
|||||||
return features.host_query_reset.hostQueryReset != VK_FALSE;
|
return features.host_query_reset.hostQueryReset != VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetMaxVertexAttribDivisor() const {
|
|
||||||
const u32 reported = properties.vertex_attribute_divisor.maxVertexAttribDivisor;
|
|
||||||
if (reported == 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return reported;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsVertexAttributeInstanceRateZeroDivisorSupported() const {
|
|
||||||
return features.vertex_attribute_divisor.vertexAttributeInstanceRateZeroDivisor == VK_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 GetVertexAttribDivisor(u32 frequency) const {
|
|
||||||
const u32 max_divisor = GetMaxVertexAttribDivisor();
|
|
||||||
if (frequency == 0) {
|
|
||||||
if (IsVertexAttributeInstanceRateZeroDivisorSupported()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return max_divisor;
|
|
||||||
}
|
|
||||||
if (frequency > max_divisor) {
|
|
||||||
return max_divisor;
|
|
||||||
}
|
|
||||||
return frequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if the device supports VK_EXT_transform_feedback.
|
/// Returns true if the device supports VK_EXT_transform_feedback.
|
||||||
bool IsExtTransformFeedbackSupported() const {
|
bool IsExtTransformFeedbackSupported() const {
|
||||||
return extensions.transform_feedback;
|
return extensions.transform_feedback;
|
||||||
@@ -1216,7 +1194,6 @@ private:
|
|||||||
VkPhysicalDeviceDescriptorBufferPropertiesEXT descriptor_buffer{};
|
VkPhysicalDeviceDescriptorBufferPropertiesEXT descriptor_buffer{};
|
||||||
VkPhysicalDeviceSubgroupSizeControlProperties subgroup_size_control{};
|
VkPhysicalDeviceSubgroupSizeControlProperties subgroup_size_control{};
|
||||||
VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback{};
|
VkPhysicalDeviceTransformFeedbackPropertiesEXT transform_feedback{};
|
||||||
VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT vertex_attribute_divisor{};
|
|
||||||
VkPhysicalDeviceMaintenance5PropertiesKHR maintenance5{};
|
VkPhysicalDeviceMaintenance5PropertiesKHR maintenance5{};
|
||||||
VkPhysicalDeviceDepthStencilResolveProperties depth_stencil_resolve{};
|
VkPhysicalDeviceDepthStencilResolveProperties depth_stencil_resolve{};
|
||||||
VkPhysicalDeviceCustomBorderColorPropertiesEXT custom_border_color{};
|
VkPhysicalDeviceCustomBorderColorPropertiesEXT custom_border_color{};
|
||||||
|
|||||||
Reference in New Issue
Block a user