mirror of https://git.suyu.dev/suyu/suyu
Merge pull request #5133 from lioncash/video-shadow2
video_core: Resolve more variable shadowing scenarios pt.2
This commit is contained in:
commit
f2f346e110
|
@ -374,43 +374,43 @@ void VP9::InsertEntropy(u64 offset, Vp9EntropyProbs& dst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vp9FrameContainer VP9::GetCurrentFrame(const NvdecCommon::NvdecRegisters& state) {
|
Vp9FrameContainer VP9::GetCurrentFrame(const NvdecCommon::NvdecRegisters& state) {
|
||||||
Vp9FrameContainer frame{};
|
Vp9FrameContainer current_frame{};
|
||||||
{
|
{
|
||||||
gpu.SyncGuestHost();
|
gpu.SyncGuestHost();
|
||||||
frame.info = GetVp9PictureInfo(state);
|
current_frame.info = GetVp9PictureInfo(state);
|
||||||
frame.bit_stream.resize(frame.info.bitstream_size);
|
current_frame.bit_stream.resize(current_frame.info.bitstream_size);
|
||||||
gpu.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.bit_stream.data(),
|
gpu.MemoryManager().ReadBlock(state.frame_bitstream_offset, current_frame.bit_stream.data(),
|
||||||
frame.info.bitstream_size);
|
current_frame.info.bitstream_size);
|
||||||
}
|
}
|
||||||
// Buffer two frames, saving the last show frame info
|
// Buffer two frames, saving the last show frame info
|
||||||
if (!next_next_frame.bit_stream.empty()) {
|
if (!next_next_frame.bit_stream.empty()) {
|
||||||
Vp9FrameContainer temp{
|
Vp9FrameContainer temp{
|
||||||
.info = frame.info,
|
.info = current_frame.info,
|
||||||
.bit_stream = std::move(frame.bit_stream),
|
.bit_stream = std::move(current_frame.bit_stream),
|
||||||
};
|
};
|
||||||
next_next_frame.info.show_frame = frame.info.last_frame_shown;
|
next_next_frame.info.show_frame = current_frame.info.last_frame_shown;
|
||||||
frame.info = next_next_frame.info;
|
current_frame.info = next_next_frame.info;
|
||||||
frame.bit_stream = std::move(next_next_frame.bit_stream);
|
current_frame.bit_stream = std::move(next_next_frame.bit_stream);
|
||||||
next_next_frame = std::move(temp);
|
next_next_frame = std::move(temp);
|
||||||
|
|
||||||
if (!next_frame.bit_stream.empty()) {
|
if (!next_frame.bit_stream.empty()) {
|
||||||
Vp9FrameContainer temp2{
|
Vp9FrameContainer temp2{
|
||||||
.info = frame.info,
|
.info = current_frame.info,
|
||||||
.bit_stream = std::move(frame.bit_stream),
|
.bit_stream = std::move(current_frame.bit_stream),
|
||||||
};
|
};
|
||||||
next_frame.info.show_frame = frame.info.last_frame_shown;
|
next_frame.info.show_frame = current_frame.info.last_frame_shown;
|
||||||
frame.info = next_frame.info;
|
current_frame.info = next_frame.info;
|
||||||
frame.bit_stream = std::move(next_frame.bit_stream);
|
current_frame.bit_stream = std::move(next_frame.bit_stream);
|
||||||
next_frame = std::move(temp2);
|
next_frame = std::move(temp2);
|
||||||
} else {
|
} else {
|
||||||
next_frame.info = frame.info;
|
next_frame.info = current_frame.info;
|
||||||
next_frame.bit_stream = std::move(frame.bit_stream);
|
next_frame.bit_stream = std::move(current_frame.bit_stream);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
next_next_frame.info = frame.info;
|
next_next_frame.info = current_frame.info;
|
||||||
next_next_frame.bit_stream = std::move(frame.bit_stream);
|
next_next_frame.bit_stream = std::move(current_frame.bit_stream);
|
||||||
}
|
}
|
||||||
return frame;
|
return current_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> VP9::ComposeCompressedHeader() {
|
std::vector<u8> VP9::ComposeCompressedHeader() {
|
||||||
|
|
|
@ -243,8 +243,8 @@ std::string BuildCommaSeparatedExtensions(std::vector<std::string> available_ext
|
||||||
RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
|
RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
|
||||||
Core::Frontend::EmuWindow& emu_window,
|
Core::Frontend::EmuWindow& emu_window,
|
||||||
Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_,
|
Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_,
|
||||||
std::unique_ptr<Core::Frontend::GraphicsContext> context)
|
std::unique_ptr<Core::Frontend::GraphicsContext> context_)
|
||||||
: RendererBase{emu_window, std::move(context)}, telemetry_session{telemetry_session_},
|
: RendererBase{emu_window, std::move(context_)}, telemetry_session{telemetry_session_},
|
||||||
cpu_memory{cpu_memory_}, gpu{gpu_} {}
|
cpu_memory{cpu_memory_}, gpu{gpu_} {}
|
||||||
|
|
||||||
RendererVulkan::~RendererVulkan() {
|
RendererVulkan::~RendererVulkan() {
|
||||||
|
|
|
@ -45,9 +45,9 @@ struct VKScreenInfo {
|
||||||
class RendererVulkan final : public VideoCore::RendererBase {
|
class RendererVulkan final : public VideoCore::RendererBase {
|
||||||
public:
|
public:
|
||||||
explicit RendererVulkan(Core::TelemetrySession& telemtry_session,
|
explicit RendererVulkan(Core::TelemetrySession& telemtry_session,
|
||||||
Core::Frontend::EmuWindow& emu_window, Core::Memory::Memory& cpu_memory,
|
Core::Frontend::EmuWindow& emu_window,
|
||||||
Tegra::GPU& gpu,
|
Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_,
|
||||||
std::unique_ptr<Core::Frontend::GraphicsContext> context);
|
std::unique_ptr<Core::Frontend::GraphicsContext> context_);
|
||||||
~RendererVulkan() override;
|
~RendererVulkan() override;
|
||||||
|
|
||||||
bool Init() override;
|
bool Init() override;
|
||||||
|
|
|
@ -461,15 +461,15 @@ VkDescriptorSet VKComputePass::CommitDescriptorSet(
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuadArrayPass::QuadArrayPass(const VKDevice& device, VKScheduler& scheduler,
|
QuadArrayPass::QuadArrayPass(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKStagingBufferPool& staging_buffer_pool,
|
VKStagingBufferPool& staging_buffer_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue)
|
VKUpdateDescriptorQueue& update_descriptor_queue_)
|
||||||
: VKComputePass(device, descriptor_pool, BuildQuadArrayPassDescriptorSetLayoutBinding(),
|
: VKComputePass(device_, descriptor_pool_, BuildQuadArrayPassDescriptorSetLayoutBinding(),
|
||||||
BuildQuadArrayPassDescriptorUpdateTemplateEntry(),
|
BuildQuadArrayPassDescriptorUpdateTemplateEntry(),
|
||||||
BuildComputePushConstantRange(sizeof(u32)), std::size(quad_array), quad_array),
|
BuildComputePushConstantRange(sizeof(u32)), std::size(quad_array), quad_array),
|
||||||
scheduler{scheduler}, staging_buffer_pool{staging_buffer_pool},
|
scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_},
|
||||||
update_descriptor_queue{update_descriptor_queue} {}
|
update_descriptor_queue{update_descriptor_queue_} {}
|
||||||
|
|
||||||
QuadArrayPass::~QuadArrayPass() = default;
|
QuadArrayPass::~QuadArrayPass() = default;
|
||||||
|
|
||||||
|
@ -510,14 +510,14 @@ std::pair<VkBuffer, VkDeviceSize> QuadArrayPass::Assemble(u32 num_vertices, u32
|
||||||
return {*buffer.handle, 0};
|
return {*buffer.handle, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8Pass::Uint8Pass(const VKDevice& device, VKScheduler& scheduler,
|
Uint8Pass::Uint8Pass(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool, VKStagingBufferPool& staging_buffer_pool,
|
VKDescriptorPool& descriptor_pool_, VKStagingBufferPool& staging_buffer_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue)
|
VKUpdateDescriptorQueue& update_descriptor_queue_)
|
||||||
: VKComputePass(device, descriptor_pool, BuildInputOutputDescriptorSetBindings(),
|
: VKComputePass(device_, descriptor_pool_, BuildInputOutputDescriptorSetBindings(),
|
||||||
BuildInputOutputDescriptorUpdateTemplate(), {}, std::size(uint8_pass),
|
BuildInputOutputDescriptorUpdateTemplate(), {}, std::size(uint8_pass),
|
||||||
uint8_pass),
|
uint8_pass),
|
||||||
scheduler{scheduler}, staging_buffer_pool{staging_buffer_pool},
|
scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_},
|
||||||
update_descriptor_queue{update_descriptor_queue} {}
|
update_descriptor_queue{update_descriptor_queue_} {}
|
||||||
|
|
||||||
Uint8Pass::~Uint8Pass() = default;
|
Uint8Pass::~Uint8Pass() = default;
|
||||||
|
|
||||||
|
@ -555,16 +555,16 @@ std::pair<VkBuffer, u64> Uint8Pass::Assemble(u32 num_vertices, VkBuffer src_buff
|
||||||
return {*buffer.handle, 0};
|
return {*buffer.handle, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
QuadIndexedPass::QuadIndexedPass(const VKDevice& device, VKScheduler& scheduler,
|
QuadIndexedPass::QuadIndexedPass(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKStagingBufferPool& staging_buffer_pool,
|
VKStagingBufferPool& staging_buffer_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue)
|
VKUpdateDescriptorQueue& update_descriptor_queue_)
|
||||||
: VKComputePass(device, descriptor_pool, BuildInputOutputDescriptorSetBindings(),
|
: VKComputePass(device_, descriptor_pool_, BuildInputOutputDescriptorSetBindings(),
|
||||||
BuildInputOutputDescriptorUpdateTemplate(),
|
BuildInputOutputDescriptorUpdateTemplate(),
|
||||||
BuildComputePushConstantRange(sizeof(u32) * 2), std::size(QUAD_INDEXED_SPV),
|
BuildComputePushConstantRange(sizeof(u32) * 2), std::size(QUAD_INDEXED_SPV),
|
||||||
QUAD_INDEXED_SPV),
|
QUAD_INDEXED_SPV),
|
||||||
scheduler{scheduler}, staging_buffer_pool{staging_buffer_pool},
|
scheduler{scheduler_}, staging_buffer_pool{staging_buffer_pool_},
|
||||||
update_descriptor_queue{update_descriptor_queue} {}
|
update_descriptor_queue{update_descriptor_queue_} {}
|
||||||
|
|
||||||
QuadIndexedPass::~QuadIndexedPass() = default;
|
QuadIndexedPass::~QuadIndexedPass() = default;
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@ private:
|
||||||
|
|
||||||
class QuadArrayPass final : public VKComputePass {
|
class QuadArrayPass final : public VKComputePass {
|
||||||
public:
|
public:
|
||||||
explicit QuadArrayPass(const VKDevice& device, VKScheduler& scheduler,
|
explicit QuadArrayPass(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKStagingBufferPool& staging_buffer_pool,
|
VKStagingBufferPool& staging_buffer_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue);
|
VKUpdateDescriptorQueue& update_descriptor_queue_);
|
||||||
~QuadArrayPass();
|
~QuadArrayPass();
|
||||||
|
|
||||||
std::pair<VkBuffer, VkDeviceSize> Assemble(u32 num_vertices, u32 first);
|
std::pair<VkBuffer, VkDeviceSize> Assemble(u32 num_vertices, u32 first);
|
||||||
|
@ -59,9 +59,10 @@ private:
|
||||||
|
|
||||||
class Uint8Pass final : public VKComputePass {
|
class Uint8Pass final : public VKComputePass {
|
||||||
public:
|
public:
|
||||||
explicit Uint8Pass(const VKDevice& device, VKScheduler& scheduler,
|
explicit Uint8Pass(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool, VKStagingBufferPool& staging_buffer_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue);
|
VKStagingBufferPool& staging_buffer_pool_,
|
||||||
|
VKUpdateDescriptorQueue& update_descriptor_queue_);
|
||||||
~Uint8Pass();
|
~Uint8Pass();
|
||||||
|
|
||||||
std::pair<VkBuffer, u64> Assemble(u32 num_vertices, VkBuffer src_buffer, u64 src_offset);
|
std::pair<VkBuffer, u64> Assemble(u32 num_vertices, VkBuffer src_buffer, u64 src_offset);
|
||||||
|
@ -74,10 +75,10 @@ private:
|
||||||
|
|
||||||
class QuadIndexedPass final : public VKComputePass {
|
class QuadIndexedPass final : public VKComputePass {
|
||||||
public:
|
public:
|
||||||
explicit QuadIndexedPass(const VKDevice& device, VKScheduler& scheduler,
|
explicit QuadIndexedPass(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKStagingBufferPool& staging_buffer_pool,
|
VKStagingBufferPool& staging_buffer_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue);
|
VKUpdateDescriptorQueue& update_descriptor_queue_);
|
||||||
~QuadIndexedPass();
|
~QuadIndexedPass();
|
||||||
|
|
||||||
std::pair<VkBuffer, u64> Assemble(Tegra::Engines::Maxwell3D::Regs::IndexFormat index_format,
|
std::pair<VkBuffer, u64> Assemble(Tegra::Engines::Maxwell3D::Regs::IndexFormat index_format,
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
VKComputePipeline::VKComputePipeline(const VKDevice& device, VKScheduler& scheduler,
|
VKComputePipeline::VKComputePipeline(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue,
|
VKUpdateDescriptorQueue& update_descriptor_queue_,
|
||||||
const SPIRVShader& shader)
|
const SPIRVShader& shader_)
|
||||||
: device{device}, scheduler{scheduler}, entries{shader.entries},
|
: device{device_}, scheduler{scheduler_}, entries{shader_.entries},
|
||||||
descriptor_set_layout{CreateDescriptorSetLayout()},
|
descriptor_set_layout{CreateDescriptorSetLayout()},
|
||||||
descriptor_allocator{descriptor_pool, *descriptor_set_layout},
|
descriptor_allocator{descriptor_pool_, *descriptor_set_layout},
|
||||||
update_descriptor_queue{update_descriptor_queue}, layout{CreatePipelineLayout()},
|
update_descriptor_queue{update_descriptor_queue_}, layout{CreatePipelineLayout()},
|
||||||
descriptor_template{CreateDescriptorUpdateTemplate()},
|
descriptor_template{CreateDescriptorUpdateTemplate()},
|
||||||
shader_module{CreateShaderModule(shader.code)}, pipeline{CreatePipeline()} {}
|
shader_module{CreateShaderModule(shader_.code)}, pipeline{CreatePipeline()} {}
|
||||||
|
|
||||||
VKComputePipeline::~VKComputePipeline() = default;
|
VKComputePipeline::~VKComputePipeline() = default;
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@ class VKUpdateDescriptorQueue;
|
||||||
|
|
||||||
class VKComputePipeline final {
|
class VKComputePipeline final {
|
||||||
public:
|
public:
|
||||||
explicit VKComputePipeline(const VKDevice& device, VKScheduler& scheduler,
|
explicit VKComputePipeline(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue,
|
VKUpdateDescriptorQueue& update_descriptor_queue_,
|
||||||
const SPIRVShader& shader);
|
const SPIRVShader& shader_);
|
||||||
~VKComputePipeline();
|
~VKComputePipeline();
|
||||||
|
|
||||||
VkDescriptorSet CommitDescriptorSet();
|
VkDescriptorSet CommitDescriptorSet();
|
||||||
|
|
|
@ -491,8 +491,8 @@ bool VKDevice::IsOptimalAstcSupported(const VkPhysicalDeviceFeatures& features)
|
||||||
VK_FORMAT_FEATURE_BLIT_DST_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
|
VK_FORMAT_FEATURE_BLIT_DST_BIT | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
|
||||||
VK_FORMAT_FEATURE_TRANSFER_DST_BIT};
|
VK_FORMAT_FEATURE_TRANSFER_DST_BIT};
|
||||||
for (const auto format : astc_formats) {
|
for (const auto format : astc_formats) {
|
||||||
const auto format_properties{physical.GetFormatProperties(format)};
|
const auto physical_format_properties{physical.GetFormatProperties(format)};
|
||||||
if (!(format_properties.optimalTilingFeatures & format_feature_usage)) {
|
if ((physical_format_properties.optimalTilingFeatures & format_feature_usage) == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,8 +644,8 @@ std::vector<const char*> VKDevice::LoadExtensions() {
|
||||||
VkPhysicalDeviceFeatures2KHR features;
|
VkPhysicalDeviceFeatures2KHR features;
|
||||||
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
|
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR;
|
||||||
|
|
||||||
VkPhysicalDeviceProperties2KHR properties;
|
VkPhysicalDeviceProperties2KHR physical_properties;
|
||||||
properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
|
physical_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR;
|
||||||
|
|
||||||
if (has_khr_shader_float16_int8) {
|
if (has_khr_shader_float16_int8) {
|
||||||
VkPhysicalDeviceFloat16Int8FeaturesKHR float16_int8_features;
|
VkPhysicalDeviceFloat16Int8FeaturesKHR float16_int8_features;
|
||||||
|
@ -670,8 +670,8 @@ std::vector<const char*> VKDevice::LoadExtensions() {
|
||||||
subgroup_properties.sType =
|
subgroup_properties.sType =
|
||||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT;
|
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT;
|
||||||
subgroup_properties.pNext = nullptr;
|
subgroup_properties.pNext = nullptr;
|
||||||
properties.pNext = &subgroup_properties;
|
physical_properties.pNext = &subgroup_properties;
|
||||||
physical.GetProperties2KHR(properties);
|
physical.GetProperties2KHR(physical_properties);
|
||||||
|
|
||||||
is_warp_potentially_bigger = subgroup_properties.maxSubgroupSize > GuestWarpSize;
|
is_warp_potentially_bigger = subgroup_properties.maxSubgroupSize > GuestWarpSize;
|
||||||
|
|
||||||
|
@ -695,8 +695,8 @@ std::vector<const char*> VKDevice::LoadExtensions() {
|
||||||
VkPhysicalDeviceTransformFeedbackPropertiesEXT tfb_properties;
|
VkPhysicalDeviceTransformFeedbackPropertiesEXT tfb_properties;
|
||||||
tfb_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
|
tfb_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT;
|
||||||
tfb_properties.pNext = nullptr;
|
tfb_properties.pNext = nullptr;
|
||||||
properties.pNext = &tfb_properties;
|
physical_properties.pNext = &tfb_properties;
|
||||||
physical.GetProperties2KHR(properties);
|
physical.GetProperties2KHR(physical_properties);
|
||||||
|
|
||||||
if (tfb_features.transformFeedback && tfb_features.geometryStreams &&
|
if (tfb_features.transformFeedback && tfb_features.geometryStreams &&
|
||||||
tfb_properties.maxTransformFeedbackStreams >= 4 &&
|
tfb_properties.maxTransformFeedbackStreams >= 4 &&
|
||||||
|
|
|
@ -14,12 +14,13 @@
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
InnerFence::InnerFence(const VKDevice& device, VKScheduler& scheduler, u32 payload, bool is_stubbed)
|
InnerFence::InnerFence(const VKDevice& device_, VKScheduler& scheduler_, u32 payload_,
|
||||||
: VideoCommon::FenceBase(payload, is_stubbed), device{device}, scheduler{scheduler} {}
|
bool is_stubbed_)
|
||||||
|
: FenceBase{payload_, is_stubbed_}, device{device_}, scheduler{scheduler_} {}
|
||||||
|
|
||||||
InnerFence::InnerFence(const VKDevice& device, VKScheduler& scheduler, GPUVAddr address,
|
InnerFence::InnerFence(const VKDevice& device_, VKScheduler& scheduler_, GPUVAddr address_,
|
||||||
u32 payload, bool is_stubbed)
|
u32 payload_, bool is_stubbed_)
|
||||||
: VideoCommon::FenceBase(address, payload, is_stubbed), device{device}, scheduler{scheduler} {}
|
: FenceBase{address_, payload_, is_stubbed_}, device{device_}, scheduler{scheduler_} {}
|
||||||
|
|
||||||
InnerFence::~InnerFence() = default;
|
InnerFence::~InnerFence() = default;
|
||||||
|
|
||||||
|
@ -71,11 +72,12 @@ bool InnerFence::IsEventSignalled() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VKFenceManager::VKFenceManager(VideoCore::RasterizerInterface& rasterizer, Tegra::GPU& gpu,
|
VKFenceManager::VKFenceManager(VideoCore::RasterizerInterface& rasterizer_, Tegra::GPU& gpu_,
|
||||||
Tegra::MemoryManager& memory_manager, VKTextureCache& texture_cache,
|
Tegra::MemoryManager& memory_manager_,
|
||||||
VKBufferCache& buffer_cache, VKQueryCache& query_cache,
|
VKTextureCache& texture_cache_, VKBufferCache& buffer_cache_,
|
||||||
const VKDevice& device_, VKScheduler& scheduler_)
|
VKQueryCache& query_cache_, const VKDevice& device_,
|
||||||
: GenericFenceManager(rasterizer, gpu, texture_cache, buffer_cache, query_cache),
|
VKScheduler& scheduler_)
|
||||||
|
: GenericFenceManager{rasterizer_, gpu_, texture_cache_, buffer_cache_, query_cache_},
|
||||||
device{device_}, scheduler{scheduler_} {}
|
device{device_}, scheduler{scheduler_} {}
|
||||||
|
|
||||||
Fence VKFenceManager::CreateFence(u32 value, bool is_stubbed) {
|
Fence VKFenceManager::CreateFence(u32 value, bool is_stubbed) {
|
||||||
|
|
|
@ -28,10 +28,10 @@ class VKTextureCache;
|
||||||
|
|
||||||
class InnerFence : public VideoCommon::FenceBase {
|
class InnerFence : public VideoCommon::FenceBase {
|
||||||
public:
|
public:
|
||||||
explicit InnerFence(const VKDevice& device, VKScheduler& scheduler, u32 payload,
|
explicit InnerFence(const VKDevice& device_, VKScheduler& scheduler_, u32 payload_,
|
||||||
bool is_stubbed);
|
bool is_stubbed_);
|
||||||
explicit InnerFence(const VKDevice& device, VKScheduler& scheduler, GPUVAddr address,
|
explicit InnerFence(const VKDevice& device_, VKScheduler& scheduler_, GPUVAddr address_,
|
||||||
u32 payload, bool is_stubbed);
|
u32 payload_, bool is_stubbed_);
|
||||||
~InnerFence();
|
~InnerFence();
|
||||||
|
|
||||||
void Queue();
|
void Queue();
|
||||||
|
@ -55,10 +55,10 @@ using GenericFenceManager =
|
||||||
|
|
||||||
class VKFenceManager final : public GenericFenceManager {
|
class VKFenceManager final : public GenericFenceManager {
|
||||||
public:
|
public:
|
||||||
explicit VKFenceManager(VideoCore::RasterizerInterface& rasterizer, Tegra::GPU& gpu,
|
explicit VKFenceManager(VideoCore::RasterizerInterface& rasterizer_, Tegra::GPU& gpu_,
|
||||||
Tegra::MemoryManager& memory_manager, VKTextureCache& texture_cache,
|
Tegra::MemoryManager& memory_manager_, VKTextureCache& texture_cache_,
|
||||||
VKBufferCache& buffer_cache, VKQueryCache& query_cache,
|
VKBufferCache& buffer_cache_, VKQueryCache& query_cache_,
|
||||||
const VKDevice& device, VKScheduler& scheduler);
|
const VKDevice& device_, VKScheduler& scheduler_);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Fence CreateFence(u32 value, bool is_stubbed) override;
|
Fence CreateFence(u32 value, bool is_stubbed) override;
|
||||||
|
|
|
@ -71,21 +71,21 @@ VkViewportSwizzleNV UnpackViewportSwizzle(u16 swizzle) {
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
VKGraphicsPipeline::VKGraphicsPipeline(const VKDevice& device, VKScheduler& scheduler,
|
VKGraphicsPipeline::VKGraphicsPipeline(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue,
|
VKUpdateDescriptorQueue& update_descriptor_queue_,
|
||||||
VKRenderPassCache& renderpass_cache,
|
VKRenderPassCache& renderpass_cache_,
|
||||||
const GraphicsPipelineCacheKey& key,
|
const GraphicsPipelineCacheKey& key_,
|
||||||
vk::Span<VkDescriptorSetLayoutBinding> bindings,
|
vk::Span<VkDescriptorSetLayoutBinding> bindings_,
|
||||||
const SPIRVProgram& program)
|
const SPIRVProgram& program_)
|
||||||
: device{device}, scheduler{scheduler}, cache_key{key}, hash{cache_key.Hash()},
|
: device{device_}, scheduler{scheduler_}, cache_key{key_}, hash{cache_key.Hash()},
|
||||||
descriptor_set_layout{CreateDescriptorSetLayout(bindings)},
|
descriptor_set_layout{CreateDescriptorSetLayout(bindings_)},
|
||||||
descriptor_allocator{descriptor_pool, *descriptor_set_layout},
|
descriptor_allocator{descriptor_pool_, *descriptor_set_layout},
|
||||||
update_descriptor_queue{update_descriptor_queue}, layout{CreatePipelineLayout()},
|
update_descriptor_queue{update_descriptor_queue_}, layout{CreatePipelineLayout()},
|
||||||
descriptor_template{CreateDescriptorUpdateTemplate(program)}, modules{CreateShaderModules(
|
descriptor_template{CreateDescriptorUpdateTemplate(program_)}, modules{CreateShaderModules(
|
||||||
program)},
|
program_)},
|
||||||
renderpass{renderpass_cache.GetRenderPass(cache_key.renderpass_params)},
|
renderpass{renderpass_cache_.GetRenderPass(cache_key.renderpass_params)},
|
||||||
pipeline{CreatePipeline(cache_key.renderpass_params, program)} {}
|
pipeline{CreatePipeline(cache_key.renderpass_params, program_)} {}
|
||||||
|
|
||||||
VKGraphicsPipeline::~VKGraphicsPipeline() = default;
|
VKGraphicsPipeline::~VKGraphicsPipeline() = default;
|
||||||
|
|
||||||
|
@ -162,8 +162,8 @@ std::vector<vk::ShaderModule> VKGraphicsPipeline::CreateShaderModules(
|
||||||
.codeSize = 0,
|
.codeSize = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<vk::ShaderModule> modules;
|
std::vector<vk::ShaderModule> shader_modules;
|
||||||
modules.reserve(Maxwell::MaxShaderStage);
|
shader_modules.reserve(Maxwell::MaxShaderStage);
|
||||||
for (std::size_t i = 0; i < Maxwell::MaxShaderStage; ++i) {
|
for (std::size_t i = 0; i < Maxwell::MaxShaderStage; ++i) {
|
||||||
const auto& stage = program[i];
|
const auto& stage = program[i];
|
||||||
if (!stage) {
|
if (!stage) {
|
||||||
|
@ -174,9 +174,9 @@ std::vector<vk::ShaderModule> VKGraphicsPipeline::CreateShaderModules(
|
||||||
|
|
||||||
ci.codeSize = stage->code.size() * sizeof(u32);
|
ci.codeSize = stage->code.size() * sizeof(u32);
|
||||||
ci.pCode = stage->code.data();
|
ci.pCode = stage->code.data();
|
||||||
modules.push_back(device.GetLogical().CreateShaderModule(ci));
|
shader_modules.push_back(device.GetLogical().CreateShaderModule(ci));
|
||||||
}
|
}
|
||||||
return modules;
|
return shader_modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
vk::Pipeline VKGraphicsPipeline::CreatePipeline(const RenderPassParams& renderpass_params,
|
vk::Pipeline VKGraphicsPipeline::CreatePipeline(const RenderPassParams& renderpass_params,
|
||||||
|
|
|
@ -51,13 +51,13 @@ using SPIRVProgram = std::array<std::optional<SPIRVShader>, Maxwell::MaxShaderSt
|
||||||
|
|
||||||
class VKGraphicsPipeline final {
|
class VKGraphicsPipeline final {
|
||||||
public:
|
public:
|
||||||
explicit VKGraphicsPipeline(const VKDevice& device, VKScheduler& scheduler,
|
explicit VKGraphicsPipeline(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VKDescriptorPool& descriptor_pool,
|
VKDescriptorPool& descriptor_pool_,
|
||||||
VKUpdateDescriptorQueue& update_descriptor_queue,
|
VKUpdateDescriptorQueue& update_descriptor_queue_,
|
||||||
VKRenderPassCache& renderpass_cache,
|
VKRenderPassCache& renderpass_cache_,
|
||||||
const GraphicsPipelineCacheKey& key,
|
const GraphicsPipelineCacheKey& key_,
|
||||||
vk::Span<VkDescriptorSetLayoutBinding> bindings,
|
vk::Span<VkDescriptorSetLayoutBinding> bindings_,
|
||||||
const SPIRVProgram& program);
|
const SPIRVProgram& program_);
|
||||||
~VKGraphicsPipeline();
|
~VKGraphicsPipeline();
|
||||||
|
|
||||||
VkDescriptorSet CommitDescriptorSet();
|
VkDescriptorSet CommitDescriptorSet();
|
||||||
|
|
|
@ -13,18 +13,18 @@
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
VKImage::VKImage(const VKDevice& device, VKScheduler& scheduler, const VkImageCreateInfo& image_ci,
|
VKImage::VKImage(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
VkImageAspectFlags aspect_mask)
|
const VkImageCreateInfo& image_ci_, VkImageAspectFlags aspect_mask_)
|
||||||
: device{device}, scheduler{scheduler}, format{image_ci.format}, aspect_mask{aspect_mask},
|
: device{device_}, scheduler{scheduler_}, format{image_ci_.format}, aspect_mask{aspect_mask_},
|
||||||
image_num_layers{image_ci.arrayLayers}, image_num_levels{image_ci.mipLevels} {
|
image_num_layers{image_ci_.arrayLayers}, image_num_levels{image_ci_.mipLevels} {
|
||||||
UNIMPLEMENTED_IF_MSG(image_ci.queueFamilyIndexCount != 0,
|
UNIMPLEMENTED_IF_MSG(image_ci_.queueFamilyIndexCount != 0,
|
||||||
"Queue family tracking is not implemented");
|
"Queue family tracking is not implemented");
|
||||||
|
|
||||||
image = device.GetLogical().CreateImage(image_ci);
|
image = device_.GetLogical().CreateImage(image_ci_);
|
||||||
|
|
||||||
const u32 num_ranges = image_num_layers * image_num_levels;
|
const u32 num_ranges = image_num_layers * image_num_levels;
|
||||||
barriers.resize(num_ranges);
|
barriers.resize(num_ranges);
|
||||||
subrange_states.resize(num_ranges, {{}, image_ci.initialLayout});
|
subrange_states.resize(num_ranges, {{}, image_ci_.initialLayout});
|
||||||
}
|
}
|
||||||
|
|
||||||
VKImage::~VKImage() = default;
|
VKImage::~VKImage() = default;
|
||||||
|
|
|
@ -17,8 +17,8 @@ class VKScheduler;
|
||||||
|
|
||||||
class VKImage {
|
class VKImage {
|
||||||
public:
|
public:
|
||||||
explicit VKImage(const VKDevice& device, VKScheduler& scheduler,
|
explicit VKImage(const VKDevice& device_, VKScheduler& scheduler_,
|
||||||
const VkImageCreateInfo& image_ci, VkImageAspectFlags aspect_mask);
|
const VkImageCreateInfo& image_ci_, VkImageAspectFlags aspect_mask_);
|
||||||
~VKImage();
|
~VKImage();
|
||||||
|
|
||||||
/// Records in the passed command buffer an image transition and updates the state of the image.
|
/// Records in the passed command buffer an image transition and updates the state of the image.
|
||||||
|
|
|
@ -29,10 +29,10 @@ u64 GetAllocationChunkSize(u64 required_size) {
|
||||||
|
|
||||||
class VKMemoryAllocation final {
|
class VKMemoryAllocation final {
|
||||||
public:
|
public:
|
||||||
explicit VKMemoryAllocation(const VKDevice& device, vk::DeviceMemory memory,
|
explicit VKMemoryAllocation(const VKDevice& device_, vk::DeviceMemory memory_,
|
||||||
VkMemoryPropertyFlags properties, u64 allocation_size, u32 type)
|
VkMemoryPropertyFlags properties_, u64 allocation_size_, u32 type_)
|
||||||
: device{device}, memory{std::move(memory)}, properties{properties},
|
: device{device_}, memory{std::move(memory_)}, properties{properties_},
|
||||||
allocation_size{allocation_size}, shifted_type{ShiftType(type)} {}
|
allocation_size{allocation_size_}, shifted_type{ShiftType(type_)} {}
|
||||||
|
|
||||||
VKMemoryCommit Commit(VkDeviceSize commit_size, VkDeviceSize alignment) {
|
VKMemoryCommit Commit(VkDeviceSize commit_size, VkDeviceSize alignment) {
|
||||||
auto found = TryFindFreeSection(free_iterator, allocation_size,
|
auto found = TryFindFreeSection(free_iterator, allocation_size,
|
||||||
|
@ -117,8 +117,8 @@ private:
|
||||||
std::vector<const VKMemoryCommitImpl*> commits;
|
std::vector<const VKMemoryCommitImpl*> commits;
|
||||||
};
|
};
|
||||||
|
|
||||||
VKMemoryManager::VKMemoryManager(const VKDevice& device)
|
VKMemoryManager::VKMemoryManager(const VKDevice& device_)
|
||||||
: device{device}, properties{device.GetPhysical().GetMemoryProperties()} {}
|
: device{device_}, properties{device_.GetPhysical().GetMemoryProperties()} {}
|
||||||
|
|
||||||
VKMemoryManager::~VKMemoryManager() = default;
|
VKMemoryManager::~VKMemoryManager() = default;
|
||||||
|
|
||||||
|
@ -207,9 +207,9 @@ VKMemoryCommit VKMemoryManager::TryAllocCommit(const VkMemoryRequirements& requi
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
VKMemoryCommitImpl::VKMemoryCommitImpl(const VKDevice& device, VKMemoryAllocation* allocation,
|
VKMemoryCommitImpl::VKMemoryCommitImpl(const VKDevice& device_, VKMemoryAllocation* allocation_,
|
||||||
const vk::DeviceMemory& memory, u64 begin, u64 end)
|
const vk::DeviceMemory& memory_, u64 begin_, u64 end_)
|
||||||
: device{device}, memory{memory}, interval{begin, end}, allocation{allocation} {}
|
: device{device_}, memory{memory_}, interval{begin_, end_}, allocation{allocation_} {}
|
||||||
|
|
||||||
VKMemoryCommitImpl::~VKMemoryCommitImpl() {
|
VKMemoryCommitImpl::~VKMemoryCommitImpl() {
|
||||||
allocation->Free(this);
|
allocation->Free(this);
|
||||||
|
|
|
@ -21,7 +21,7 @@ using VKMemoryCommit = std::unique_ptr<VKMemoryCommitImpl>;
|
||||||
|
|
||||||
class VKMemoryManager final {
|
class VKMemoryManager final {
|
||||||
public:
|
public:
|
||||||
explicit VKMemoryManager(const VKDevice& device);
|
explicit VKMemoryManager(const VKDevice& device_);
|
||||||
VKMemoryManager(const VKMemoryManager&) = delete;
|
VKMemoryManager(const VKMemoryManager&) = delete;
|
||||||
~VKMemoryManager();
|
~VKMemoryManager();
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ class VKMemoryCommitImpl final {
|
||||||
friend MemoryMap;
|
friend MemoryMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VKMemoryCommitImpl(const VKDevice& device, VKMemoryAllocation* allocation,
|
explicit VKMemoryCommitImpl(const VKDevice& device_, VKMemoryAllocation* allocation_,
|
||||||
const vk::DeviceMemory& memory, u64 begin, u64 end);
|
const vk::DeviceMemory& memory_, u64 begin_, u64 end_);
|
||||||
~VKMemoryCommitImpl();
|
~VKMemoryCommitImpl();
|
||||||
|
|
||||||
/// Maps a memory region and returns a pointer to it.
|
/// Maps a memory region and returns a pointer to it.
|
||||||
|
@ -93,8 +93,8 @@ private:
|
||||||
/// Holds ownership of a memory map.
|
/// Holds ownership of a memory map.
|
||||||
class MemoryMap final {
|
class MemoryMap final {
|
||||||
public:
|
public:
|
||||||
explicit MemoryMap(const VKMemoryCommitImpl* commit, u8* address)
|
explicit MemoryMap(const VKMemoryCommitImpl* commit_, u8* address_)
|
||||||
: commit{commit}, address{address} {}
|
: commit{commit_}, address{address_} {}
|
||||||
|
|
||||||
~MemoryMap() {
|
~MemoryMap() {
|
||||||
if (commit) {
|
if (commit) {
|
||||||
|
|
|
@ -66,15 +66,15 @@ void QueryPool::Reserve(std::pair<VkQueryPool, u32> query) {
|
||||||
usage[pool_index * GROW_STEP + static_cast<std::ptrdiff_t>(query.second)] = false;
|
usage[pool_index * GROW_STEP + static_cast<std::ptrdiff_t>(query.second)] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VKQueryCache::VKQueryCache(VideoCore::RasterizerInterface& rasterizer,
|
VKQueryCache::VKQueryCache(VideoCore::RasterizerInterface& rasterizer_,
|
||||||
Tegra::Engines::Maxwell3D& maxwell3d, Tegra::MemoryManager& gpu_memory,
|
Tegra::Engines::Maxwell3D& maxwell3d_, Tegra::MemoryManager& gpu_memory_,
|
||||||
const VKDevice& device, VKScheduler& scheduler)
|
const VKDevice& device_, VKScheduler& scheduler_)
|
||||||
: VideoCommon::QueryCacheBase<VKQueryCache, CachedQuery, CounterStream,
|
: QueryCacheBase<VKQueryCache, CachedQuery, CounterStream, HostCounter>{rasterizer_, maxwell3d_,
|
||||||
HostCounter>{rasterizer, maxwell3d, gpu_memory},
|
gpu_memory_},
|
||||||
device{device}, scheduler{scheduler}, query_pools{
|
device{device_}, scheduler{scheduler_}, query_pools{
|
||||||
QueryPool{device, scheduler,
|
QueryPool{device_, scheduler_,
|
||||||
QueryType::SamplesPassed},
|
QueryType::SamplesPassed},
|
||||||
} {}
|
} {}
|
||||||
|
|
||||||
VKQueryCache::~VKQueryCache() {
|
VKQueryCache::~VKQueryCache() {
|
||||||
// TODO(Rodrigo): This is a hack to destroy all HostCounter instances before the base class
|
// TODO(Rodrigo): This is a hack to destroy all HostCounter instances before the base class
|
||||||
|
@ -95,12 +95,12 @@ void VKQueryCache::Reserve(QueryType type, std::pair<VkQueryPool, u32> query) {
|
||||||
query_pools[static_cast<std::size_t>(type)].Reserve(query);
|
query_pools[static_cast<std::size_t>(type)].Reserve(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
HostCounter::HostCounter(VKQueryCache& cache, std::shared_ptr<HostCounter> dependency,
|
HostCounter::HostCounter(VKQueryCache& cache_, std::shared_ptr<HostCounter> dependency_,
|
||||||
QueryType type)
|
QueryType type_)
|
||||||
: VideoCommon::HostCounterBase<VKQueryCache, HostCounter>{std::move(dependency)}, cache{cache},
|
: HostCounterBase<VKQueryCache, HostCounter>{std::move(dependency_)}, cache{cache_},
|
||||||
type{type}, query{cache.AllocateQuery(type)}, tick{cache.Scheduler().CurrentTick()} {
|
type{type_}, query{cache_.AllocateQuery(type_)}, tick{cache_.Scheduler().CurrentTick()} {
|
||||||
const vk::Device* logical = &cache.Device().GetLogical();
|
const vk::Device* logical = &cache_.Device().GetLogical();
|
||||||
cache.Scheduler().Record([logical, query = query](vk::CommandBuffer cmdbuf) {
|
cache_.Scheduler().Record([logical, query = query](vk::CommandBuffer cmdbuf) {
|
||||||
logical->ResetQueryPoolEXT(query.first, query.second, 1);
|
logical->ResetQueryPoolEXT(query.first, query.second, 1);
|
||||||
cmdbuf.BeginQuery(query.first, query.second, VK_QUERY_CONTROL_PRECISE_BIT);
|
cmdbuf.BeginQuery(query.first, query.second, VK_QUERY_CONTROL_PRECISE_BIT);
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,9 +53,9 @@ private:
|
||||||
class VKQueryCache final
|
class VKQueryCache final
|
||||||
: public VideoCommon::QueryCacheBase<VKQueryCache, CachedQuery, CounterStream, HostCounter> {
|
: public VideoCommon::QueryCacheBase<VKQueryCache, CachedQuery, CounterStream, HostCounter> {
|
||||||
public:
|
public:
|
||||||
explicit VKQueryCache(VideoCore::RasterizerInterface& rasterizer,
|
explicit VKQueryCache(VideoCore::RasterizerInterface& rasterizer_,
|
||||||
Tegra::Engines::Maxwell3D& maxwell3d, Tegra::MemoryManager& gpu_memory,
|
Tegra::Engines::Maxwell3D& maxwell3d_, Tegra::MemoryManager& gpu_memory_,
|
||||||
const VKDevice& device, VKScheduler& scheduler);
|
const VKDevice& device_, VKScheduler& scheduler_);
|
||||||
~VKQueryCache();
|
~VKQueryCache();
|
||||||
|
|
||||||
std::pair<VkQueryPool, u32> AllocateQuery(VideoCore::QueryType type);
|
std::pair<VkQueryPool, u32> AllocateQuery(VideoCore::QueryType type);
|
||||||
|
@ -78,8 +78,8 @@ private:
|
||||||
|
|
||||||
class HostCounter final : public VideoCommon::HostCounterBase<VKQueryCache, HostCounter> {
|
class HostCounter final : public VideoCommon::HostCounterBase<VKQueryCache, HostCounter> {
|
||||||
public:
|
public:
|
||||||
explicit HostCounter(VKQueryCache& cache, std::shared_ptr<HostCounter> dependency,
|
explicit HostCounter(VKQueryCache& cache_, std::shared_ptr<HostCounter> dependency_,
|
||||||
VideoCore::QueryType type);
|
VideoCore::QueryType type_);
|
||||||
~HostCounter();
|
~HostCounter();
|
||||||
|
|
||||||
void EndQuery();
|
void EndQuery();
|
||||||
|
|
|
@ -904,15 +904,14 @@ void RasterizerVulkan::SetupShaderDescriptors(
|
||||||
texture_cache.GuardSamplers(false);
|
texture_cache.GuardSamplers(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::SetupImageTransitions(
|
void RasterizerVulkan::SetupImageTransitions(Texceptions texceptions, const ColorAttachments& color,
|
||||||
Texceptions texceptions, const std::array<View, Maxwell::NumRenderTargets>& color_attachments,
|
const ZetaAttachment& zeta) {
|
||||||
const View& zeta_attachment) {
|
|
||||||
TransitionImages(sampled_views, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, VK_ACCESS_SHADER_READ_BIT);
|
TransitionImages(sampled_views, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, VK_ACCESS_SHADER_READ_BIT);
|
||||||
TransitionImages(image_views, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
|
TransitionImages(image_views, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
|
||||||
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
|
VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
|
||||||
|
|
||||||
for (std::size_t rt = 0; rt < std::size(color_attachments); ++rt) {
|
for (std::size_t rt = 0; rt < color.size(); ++rt) {
|
||||||
const auto color_attachment = color_attachments[rt];
|
const auto color_attachment = color[rt];
|
||||||
if (color_attachment == nullptr) {
|
if (color_attachment == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -923,13 +922,13 @@ void RasterizerVulkan::SetupImageTransitions(
|
||||||
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
|
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zeta_attachment != nullptr) {
|
if (zeta != nullptr) {
|
||||||
const auto image_layout = texceptions[ZETA_TEXCEPTION_INDEX]
|
const auto image_layout = texceptions[ZETA_TEXCEPTION_INDEX]
|
||||||
? VK_IMAGE_LAYOUT_GENERAL
|
? VK_IMAGE_LAYOUT_GENERAL
|
||||||
: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
: VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
||||||
zeta_attachment->Transition(image_layout, VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT,
|
zeta->Transition(image_layout, VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,6 +160,9 @@ private:
|
||||||
bool is_indexed = 0;
|
bool is_indexed = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using ColorAttachments = std::array<View, Maxwell::NumRenderTargets>;
|
||||||
|
using ZetaAttachment = View;
|
||||||
|
|
||||||
using Texceptions = std::bitset<Maxwell::NumRenderTargets + 1>;
|
using Texceptions = std::bitset<Maxwell::NumRenderTargets + 1>;
|
||||||
|
|
||||||
static constexpr std::size_t ZETA_TEXCEPTION_INDEX = 8;
|
static constexpr std::size_t ZETA_TEXCEPTION_INDEX = 8;
|
||||||
|
@ -181,9 +184,8 @@ private:
|
||||||
/// Setup descriptors in the graphics pipeline.
|
/// Setup descriptors in the graphics pipeline.
|
||||||
void SetupShaderDescriptors(const std::array<Shader*, Maxwell::MaxShaderProgram>& shaders);
|
void SetupShaderDescriptors(const std::array<Shader*, Maxwell::MaxShaderProgram>& shaders);
|
||||||
|
|
||||||
void SetupImageTransitions(Texceptions texceptions,
|
void SetupImageTransitions(Texceptions texceptions, const ColorAttachments& color,
|
||||||
const std::array<View, Maxwell::NumRenderTargets>& color_attachments,
|
const ZetaAttachment& zeta);
|
||||||
const View& zeta_attachment);
|
|
||||||
|
|
||||||
void UpdateDynamicStates();
|
void UpdateDynamicStates();
|
||||||
|
|
||||||
|
@ -308,8 +310,8 @@ private:
|
||||||
vk::Event wfi_event;
|
vk::Event wfi_event;
|
||||||
VideoCommon::Shader::AsyncShaders async_shaders;
|
VideoCommon::Shader::AsyncShaders async_shaders;
|
||||||
|
|
||||||
std::array<View, Maxwell::NumRenderTargets> color_attachments;
|
ColorAttachments color_attachments;
|
||||||
View zeta_attachment;
|
ZetaAttachment zeta_attachment;
|
||||||
|
|
||||||
std::vector<ImageView> sampled_views;
|
std::vector<ImageView> sampled_views;
|
||||||
std::vector<ImageView> image_views;
|
std::vector<ImageView> image_views;
|
||||||
|
|
|
@ -24,7 +24,7 @@ bool RenderPassParams::operator==(const RenderPassParams& rhs) const noexcept {
|
||||||
return std::memcmp(&rhs, this, sizeof *this) == 0;
|
return std::memcmp(&rhs, this, sizeof *this) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VKRenderPassCache::VKRenderPassCache(const VKDevice& device) : device{device} {}
|
VKRenderPassCache::VKRenderPassCache(const VKDevice& device_) : device{device_} {}
|
||||||
|
|
||||||
VKRenderPassCache::~VKRenderPassCache() = default;
|
VKRenderPassCache::~VKRenderPassCache() = default;
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Vulkan {
|
||||||
|
|
||||||
class VKRenderPassCache final {
|
class VKRenderPassCache final {
|
||||||
public:
|
public:
|
||||||
explicit VKRenderPassCache(const VKDevice& device);
|
explicit VKRenderPassCache(const VKDevice& device_);
|
||||||
~VKRenderPassCache();
|
~VKRenderPassCache();
|
||||||
|
|
||||||
VkRenderPass GetRenderPass(const RenderPassParams& params);
|
VkRenderPass GetRenderPass(const RenderPassParams& params);
|
||||||
|
|
|
@ -36,7 +36,7 @@ VkBorderColor ConvertBorderColor(std::array<float, 4> color) {
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
VKSamplerCache::VKSamplerCache(const VKDevice& device) : device{device} {}
|
VKSamplerCache::VKSamplerCache(const VKDevice& device_) : device{device_} {}
|
||||||
|
|
||||||
VKSamplerCache::~VKSamplerCache() = default;
|
VKSamplerCache::~VKSamplerCache() = default;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class VKDevice;
|
||||||
|
|
||||||
class VKSamplerCache final : public VideoCommon::SamplerCache<VkSampler, vk::Sampler> {
|
class VKSamplerCache final : public VideoCommon::SamplerCache<VkSampler, vk::Sampler> {
|
||||||
public:
|
public:
|
||||||
explicit VKSamplerCache(const VKDevice& device);
|
explicit VKSamplerCache(const VKDevice& device_);
|
||||||
~VKSamplerCache();
|
~VKSamplerCache();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -104,7 +104,7 @@ private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TypedCommand final : public Command {
|
class TypedCommand final : public Command {
|
||||||
public:
|
public:
|
||||||
explicit TypedCommand(T&& command) : command{std::move(command)} {}
|
explicit TypedCommand(T&& command_) : command{std::move(command_)} {}
|
||||||
~TypedCommand() override = default;
|
~TypedCommand() override = default;
|
||||||
|
|
||||||
TypedCommand(TypedCommand&&) = delete;
|
TypedCommand(TypedCommand&&) = delete;
|
||||||
|
|
|
@ -55,8 +55,8 @@ enum class Type { Void, Bool, Bool2, Float, Int, Uint, HalfFloat };
|
||||||
|
|
||||||
class Expression final {
|
class Expression final {
|
||||||
public:
|
public:
|
||||||
Expression(Id id, Type type) : id{id}, type{type} {
|
Expression(Id id_, Type type_) : id{id_}, type{type_} {
|
||||||
ASSERT(type != Type::Void);
|
ASSERT(type_ != Type::Void);
|
||||||
}
|
}
|
||||||
Expression() : type{Type::Void} {}
|
Expression() : type{Type::Void} {}
|
||||||
|
|
||||||
|
@ -281,12 +281,12 @@ u32 ShaderVersion(const VKDevice& device) {
|
||||||
|
|
||||||
class SPIRVDecompiler final : public Sirit::Module {
|
class SPIRVDecompiler final : public Sirit::Module {
|
||||||
public:
|
public:
|
||||||
explicit SPIRVDecompiler(const VKDevice& device, const ShaderIR& ir, ShaderType stage,
|
explicit SPIRVDecompiler(const VKDevice& device_, const ShaderIR& ir_, ShaderType stage_,
|
||||||
const Registry& registry, const Specialization& specialization)
|
const Registry& registry_, const Specialization& specialization_)
|
||||||
: Module(ShaderVersion(device)), device{device}, ir{ir}, stage{stage},
|
: Module(ShaderVersion(device_)), device{device_}, ir{ir_}, stage{stage_},
|
||||||
header{ir.GetHeader()}, registry{registry}, specialization{specialization} {
|
header{ir_.GetHeader()}, registry{registry_}, specialization{specialization_} {
|
||||||
if (stage != ShaderType::Compute) {
|
if (stage_ != ShaderType::Compute) {
|
||||||
transform_feedback = BuildTransformFeedback(registry.GetGraphicsInfo());
|
transform_feedback = BuildTransformFeedback(registry_.GetGraphicsInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
AddCapability(spv::Capability::Shader);
|
AddCapability(spv::Capability::Shader);
|
||||||
|
@ -330,7 +330,7 @@ public:
|
||||||
if (device.IsFloat16Supported()) {
|
if (device.IsFloat16Supported()) {
|
||||||
AddCapability(spv::Capability::Float16);
|
AddCapability(spv::Capability::Float16);
|
||||||
}
|
}
|
||||||
t_scalar_half = Name(TypeFloat(device.IsFloat16Supported() ? 16 : 32), "scalar_half");
|
t_scalar_half = Name(TypeFloat(device_.IsFloat16Supported() ? 16 : 32), "scalar_half");
|
||||||
t_half = Name(TypeVector(t_scalar_half, 2), "half");
|
t_half = Name(TypeVector(t_scalar_half, 2), "half");
|
||||||
|
|
||||||
const Id main = Decompile();
|
const Id main = Decompile();
|
||||||
|
@ -1088,9 +1088,9 @@ private:
|
||||||
indices.point_size = AddBuiltIn(t_float, spv::BuiltIn::PointSize, "point_size");
|
indices.point_size = AddBuiltIn(t_float, spv::BuiltIn::PointSize, "point_size");
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& output_attributes = ir.GetOutputAttributes();
|
const auto& ir_output_attributes = ir.GetOutputAttributes();
|
||||||
const bool declare_clip_distances =
|
const bool declare_clip_distances = std::any_of(
|
||||||
std::any_of(output_attributes.begin(), output_attributes.end(), [](const auto& index) {
|
ir_output_attributes.begin(), ir_output_attributes.end(), [](const auto& index) {
|
||||||
return index == Attribute::Index::ClipDistances0123 ||
|
return index == Attribute::Index::ClipDistances0123 ||
|
||||||
index == Attribute::Index::ClipDistances4567;
|
index == Attribute::Index::ClipDistances4567;
|
||||||
});
|
});
|
||||||
|
@ -2891,7 +2891,7 @@ private:
|
||||||
|
|
||||||
class ExprDecompiler {
|
class ExprDecompiler {
|
||||||
public:
|
public:
|
||||||
explicit ExprDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {}
|
explicit ExprDecompiler(SPIRVDecompiler& decomp_) : decomp{decomp_} {}
|
||||||
|
|
||||||
Id operator()(const ExprAnd& expr) {
|
Id operator()(const ExprAnd& expr) {
|
||||||
const Id type_def = decomp.GetTypeDefinition(Type::Bool);
|
const Id type_def = decomp.GetTypeDefinition(Type::Bool);
|
||||||
|
@ -2947,7 +2947,7 @@ private:
|
||||||
|
|
||||||
class ASTDecompiler {
|
class ASTDecompiler {
|
||||||
public:
|
public:
|
||||||
explicit ASTDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {}
|
explicit ASTDecompiler(SPIRVDecompiler& decomp_) : decomp{decomp_} {}
|
||||||
|
|
||||||
void operator()(const ASTProgram& ast) {
|
void operator()(const ASTProgram& ast) {
|
||||||
ASTNode current = ast.nodes.GetFirst();
|
ASTNode current = ast.nodes.GetFirst();
|
||||||
|
|
|
@ -30,8 +30,8 @@ constexpr u32 DESCRIPTOR_SET = 0;
|
||||||
|
|
||||||
class ConstBufferEntry : public VideoCommon::Shader::ConstBuffer {
|
class ConstBufferEntry : public VideoCommon::Shader::ConstBuffer {
|
||||||
public:
|
public:
|
||||||
explicit constexpr ConstBufferEntry(const VideoCommon::Shader::ConstBuffer& entry, u32 index)
|
explicit constexpr ConstBufferEntry(const ConstBuffer& entry_, u32 index_)
|
||||||
: VideoCommon::Shader::ConstBuffer{entry}, index{index} {}
|
: ConstBuffer{entry_}, index{index_} {}
|
||||||
|
|
||||||
constexpr u32 GetIndex() const {
|
constexpr u32 GetIndex() const {
|
||||||
return index;
|
return index;
|
||||||
|
@ -43,8 +43,8 @@ private:
|
||||||
|
|
||||||
class GlobalBufferEntry {
|
class GlobalBufferEntry {
|
||||||
public:
|
public:
|
||||||
constexpr explicit GlobalBufferEntry(u32 cbuf_index, u32 cbuf_offset, bool is_written)
|
constexpr explicit GlobalBufferEntry(u32 cbuf_index_, u32 cbuf_offset_, bool is_written_)
|
||||||
: cbuf_index{cbuf_index}, cbuf_offset{cbuf_offset}, is_written{is_written} {}
|
: cbuf_index{cbuf_index_}, cbuf_offset{cbuf_offset_}, is_written{is_written_} {}
|
||||||
|
|
||||||
constexpr u32 GetCbufIndex() const {
|
constexpr u32 GetCbufIndex() const {
|
||||||
return cbuf_index;
|
return cbuf_index;
|
||||||
|
|
|
@ -180,19 +180,19 @@ VkImageCreateInfo GenerateImageCreateInfo(const VKDevice& device, const SurfaceP
|
||||||
return ci;
|
return ci;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 EncodeSwizzle(Tegra::Texture::SwizzleSource x_source, Tegra::Texture::SwizzleSource y_source,
|
u32 EncodeSwizzle(SwizzleSource x_source, SwizzleSource y_source, SwizzleSource z_source,
|
||||||
Tegra::Texture::SwizzleSource z_source, Tegra::Texture::SwizzleSource w_source) {
|
SwizzleSource w_source) {
|
||||||
return (static_cast<u32>(x_source) << 24) | (static_cast<u32>(y_source) << 16) |
|
return (static_cast<u32>(x_source) << 24) | (static_cast<u32>(y_source) << 16) |
|
||||||
(static_cast<u32>(z_source) << 8) | static_cast<u32>(w_source);
|
(static_cast<u32>(z_source) << 8) | static_cast<u32>(w_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
CachedSurface::CachedSurface(const VKDevice& device, VKMemoryManager& memory_manager,
|
CachedSurface::CachedSurface(const VKDevice& device_, VKMemoryManager& memory_manager_,
|
||||||
VKScheduler& scheduler, VKStagingBufferPool& staging_pool,
|
VKScheduler& scheduler_, VKStagingBufferPool& staging_pool_,
|
||||||
GPUVAddr gpu_addr, const SurfaceParams& params)
|
GPUVAddr gpu_addr_, const SurfaceParams& params_)
|
||||||
: SurfaceBase<View>{gpu_addr, params, device.IsOptimalAstcSupported()}, device{device},
|
: SurfaceBase<View>{gpu_addr_, params_, device_.IsOptimalAstcSupported()}, device{device_},
|
||||||
memory_manager{memory_manager}, scheduler{scheduler}, staging_pool{staging_pool} {
|
memory_manager{memory_manager_}, scheduler{scheduler_}, staging_pool{staging_pool_} {
|
||||||
if (params.IsBuffer()) {
|
if (params.IsBuffer()) {
|
||||||
buffer = CreateBuffer(device, params, host_memory_size);
|
buffer = CreateBuffer(device, params, host_memory_size);
|
||||||
commit = memory_manager.Commit(buffer, false);
|
commit = memory_manager.Commit(buffer, false);
|
||||||
|
@ -234,7 +234,7 @@ void CachedSurface::UploadTexture(const std::vector<u8>& staging_buffer) {
|
||||||
void CachedSurface::DownloadTexture(std::vector<u8>& staging_buffer) {
|
void CachedSurface::DownloadTexture(std::vector<u8>& staging_buffer) {
|
||||||
UNIMPLEMENTED_IF(params.IsBuffer());
|
UNIMPLEMENTED_IF(params.IsBuffer());
|
||||||
|
|
||||||
if (params.pixel_format == VideoCore::Surface::PixelFormat::A1B5G5R5_UNORM) {
|
if (params.pixel_format == PixelFormat::A1B5G5R5_UNORM) {
|
||||||
LOG_WARNING(Render_Vulkan, "A1B5G5R5 flushing is stubbed");
|
LOG_WARNING(Render_Vulkan, "A1B5G5R5 flushing is stubbed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,10 +244,10 @@ void CachedSurface::DownloadTexture(std::vector<u8>& staging_buffer) {
|
||||||
FullTransition(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT,
|
FullTransition(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT,
|
||||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||||
|
|
||||||
const auto& buffer = staging_pool.GetUnusedBuffer(host_memory_size, true);
|
const auto& unused_buffer = staging_pool.GetUnusedBuffer(host_memory_size, true);
|
||||||
// TODO(Rodrigo): Do this in a single copy
|
// TODO(Rodrigo): Do this in a single copy
|
||||||
for (u32 level = 0; level < params.num_levels; ++level) {
|
for (u32 level = 0; level < params.num_levels; ++level) {
|
||||||
scheduler.Record([image = *image->GetHandle(), buffer = *buffer.handle,
|
scheduler.Record([image = *image->GetHandle(), buffer = *unused_buffer.handle,
|
||||||
copy = GetBufferImageCopy(level)](vk::CommandBuffer cmdbuf) {
|
copy = GetBufferImageCopy(level)](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.CopyImageToBuffer(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buffer, copy);
|
cmdbuf.CopyImageToBuffer(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, buffer, copy);
|
||||||
});
|
});
|
||||||
|
@ -255,16 +255,17 @@ void CachedSurface::DownloadTexture(std::vector<u8>& staging_buffer) {
|
||||||
scheduler.Finish();
|
scheduler.Finish();
|
||||||
|
|
||||||
// TODO(Rodrigo): Use an intern buffer for staging buffers and avoid this unnecessary memcpy.
|
// TODO(Rodrigo): Use an intern buffer for staging buffers and avoid this unnecessary memcpy.
|
||||||
std::memcpy(staging_buffer.data(), buffer.commit->Map(host_memory_size), host_memory_size);
|
std::memcpy(staging_buffer.data(), unused_buffer.commit->Map(host_memory_size),
|
||||||
|
host_memory_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CachedSurface::DecorateSurfaceName() {
|
void CachedSurface::DecorateSurfaceName() {
|
||||||
// TODO(Rodrigo): Add name decorations
|
// TODO(Rodrigo): Add name decorations
|
||||||
}
|
}
|
||||||
|
|
||||||
View CachedSurface::CreateView(const ViewParams& params) {
|
View CachedSurface::CreateView(const ViewParams& view_params) {
|
||||||
// TODO(Rodrigo): Add name decorations
|
// TODO(Rodrigo): Add name decorations
|
||||||
return views[params] = std::make_shared<CachedSurfaceView>(device, *this, params);
|
return views[view_params] = std::make_shared<CachedSurfaceView>(device, *this, view_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CachedSurface::UploadBuffer(const std::vector<u8>& staging_buffer) {
|
void CachedSurface::UploadBuffer(const std::vector<u8>& staging_buffer) {
|
||||||
|
@ -348,21 +349,21 @@ VkImageSubresourceRange CachedSurface::GetImageSubresourceRange() const {
|
||||||
static_cast<u32>(params.GetNumLayers())};
|
static_cast<u32>(params.GetNumLayers())};
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedSurfaceView::CachedSurfaceView(const VKDevice& device, CachedSurface& surface,
|
CachedSurfaceView::CachedSurfaceView(const VKDevice& device_, CachedSurface& surface_,
|
||||||
const ViewParams& params)
|
const ViewParams& view_params_)
|
||||||
: VideoCommon::ViewBase{params}, params{surface.GetSurfaceParams()},
|
: ViewBase{view_params_}, surface_params{surface_.GetSurfaceParams()},
|
||||||
image{surface.GetImageHandle()}, buffer_view{surface.GetBufferViewHandle()},
|
image{surface_.GetImageHandle()}, buffer_view{surface_.GetBufferViewHandle()},
|
||||||
aspect_mask{surface.GetAspectMask()}, device{device}, surface{surface},
|
aspect_mask{surface_.GetAspectMask()}, device{device_}, surface{surface_},
|
||||||
base_level{params.base_level}, num_levels{params.num_levels},
|
base_level{view_params_.base_level}, num_levels{view_params_.num_levels},
|
||||||
image_view_type{image ? GetImageViewType(params.target) : VK_IMAGE_VIEW_TYPE_1D} {
|
image_view_type{image ? GetImageViewType(view_params_.target) : VK_IMAGE_VIEW_TYPE_1D} {
|
||||||
if (image_view_type == VK_IMAGE_VIEW_TYPE_3D) {
|
if (image_view_type == VK_IMAGE_VIEW_TYPE_3D) {
|
||||||
base_layer = 0;
|
base_layer = 0;
|
||||||
num_layers = 1;
|
num_layers = 1;
|
||||||
base_slice = params.base_layer;
|
base_slice = view_params_.base_layer;
|
||||||
num_slices = params.num_layers;
|
num_slices = view_params_.num_layers;
|
||||||
} else {
|
} else {
|
||||||
base_layer = params.base_layer;
|
base_layer = view_params_.base_layer;
|
||||||
num_layers = params.num_layers;
|
num_layers = view_params_.num_layers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +385,7 @@ VkImageView CachedSurfaceView::GetImageView(SwizzleSource x_source, SwizzleSourc
|
||||||
|
|
||||||
std::array swizzle{MaxwellToVK::SwizzleSource(x_source), MaxwellToVK::SwizzleSource(y_source),
|
std::array swizzle{MaxwellToVK::SwizzleSource(x_source), MaxwellToVK::SwizzleSource(y_source),
|
||||||
MaxwellToVK::SwizzleSource(z_source), MaxwellToVK::SwizzleSource(w_source)};
|
MaxwellToVK::SwizzleSource(z_source), MaxwellToVK::SwizzleSource(w_source)};
|
||||||
if (params.pixel_format == VideoCore::Surface::PixelFormat::A1B5G5R5_UNORM) {
|
if (surface_params.pixel_format == PixelFormat::A1B5G5R5_UNORM) {
|
||||||
// A1B5G5R5 is implemented as A1R5G5B5, we have to change the swizzle here.
|
// A1B5G5R5 is implemented as A1R5G5B5, we have to change the swizzle here.
|
||||||
std::swap(swizzle[0], swizzle[2]);
|
std::swap(swizzle[0], swizzle[2]);
|
||||||
}
|
}
|
||||||
|
@ -395,12 +396,12 @@ VkImageView CachedSurfaceView::GetImageView(SwizzleSource x_source, SwizzleSourc
|
||||||
if (aspect == (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
if (aspect == (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
||||||
UNIMPLEMENTED_IF(x_source != SwizzleSource::R && x_source != SwizzleSource::G);
|
UNIMPLEMENTED_IF(x_source != SwizzleSource::R && x_source != SwizzleSource::G);
|
||||||
const bool is_first = x_source == SwizzleSource::R;
|
const bool is_first = x_source == SwizzleSource::R;
|
||||||
switch (params.pixel_format) {
|
switch (surface_params.pixel_format) {
|
||||||
case VideoCore::Surface::PixelFormat::D24_UNORM_S8_UINT:
|
case PixelFormat::D24_UNORM_S8_UINT:
|
||||||
case VideoCore::Surface::PixelFormat::D32_FLOAT_S8_UINT:
|
case PixelFormat::D32_FLOAT_S8_UINT:
|
||||||
aspect = is_first ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT;
|
aspect = is_first ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||||
break;
|
break;
|
||||||
case VideoCore::Surface::PixelFormat::S8_UINT_D24_UNORM:
|
case PixelFormat::S8_UINT_D24_UNORM:
|
||||||
aspect = is_first ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
|
aspect = is_first ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -417,7 +418,7 @@ VkImageView CachedSurfaceView::GetImageView(SwizzleSource x_source, SwizzleSourc
|
||||||
|
|
||||||
if (image_view_type == VK_IMAGE_VIEW_TYPE_3D) {
|
if (image_view_type == VK_IMAGE_VIEW_TYPE_3D) {
|
||||||
ASSERT(base_slice == 0);
|
ASSERT(base_slice == 0);
|
||||||
ASSERT(num_slices == params.depth);
|
ASSERT(num_slices == surface_params.depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
image_view = device.GetLogical().CreateImageView({
|
image_view = device.GetLogical().CreateImageView({
|
||||||
|
|
|
@ -40,9 +40,9 @@ class CachedSurface final : public VideoCommon::SurfaceBase<View> {
|
||||||
friend CachedSurfaceView;
|
friend CachedSurfaceView;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CachedSurface(const VKDevice& device, VKMemoryManager& memory_manager,
|
explicit CachedSurface(const VKDevice& device_, VKMemoryManager& memory_manager_,
|
||||||
VKScheduler& scheduler, VKStagingBufferPool& staging_pool,
|
VKScheduler& scheduler_, VKStagingBufferPool& staging_pool_,
|
||||||
GPUVAddr gpu_addr, const SurfaceParams& params);
|
GPUVAddr gpu_addr_, const SurfaceParams& params_);
|
||||||
~CachedSurface();
|
~CachedSurface();
|
||||||
|
|
||||||
void UploadTexture(const std::vector<u8>& staging_buffer) override;
|
void UploadTexture(const std::vector<u8>& staging_buffer) override;
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void DecorateSurfaceName();
|
void DecorateSurfaceName();
|
||||||
|
|
||||||
View CreateView(const ViewParams& params) override;
|
View CreateView(const ViewParams& view_params) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UploadBuffer(const std::vector<u8>& staging_buffer);
|
void UploadBuffer(const std::vector<u8>& staging_buffer);
|
||||||
|
@ -110,8 +110,8 @@ private:
|
||||||
|
|
||||||
class CachedSurfaceView final : public VideoCommon::ViewBase {
|
class CachedSurfaceView final : public VideoCommon::ViewBase {
|
||||||
public:
|
public:
|
||||||
explicit CachedSurfaceView(const VKDevice& device, CachedSurface& surface,
|
explicit CachedSurfaceView(const VKDevice& device_, CachedSurface& surface_,
|
||||||
const ViewParams& params);
|
const ViewParams& view_params_);
|
||||||
~CachedSurfaceView();
|
~CachedSurfaceView();
|
||||||
|
|
||||||
VkImageView GetImageView(Tegra::Texture::SwizzleSource x_source,
|
VkImageView GetImageView(Tegra::Texture::SwizzleSource x_source,
|
||||||
|
@ -126,11 +126,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetWidth() const {
|
u32 GetWidth() const {
|
||||||
return params.GetMipWidth(base_level);
|
return surface_params.GetMipWidth(base_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetHeight() const {
|
u32 GetHeight() const {
|
||||||
return params.GetMipHeight(base_level);
|
return surface_params.GetMipHeight(base_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetNumLayers() const {
|
u32 GetNumLayers() const {
|
||||||
|
@ -169,7 +169,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Store a copy of these values to avoid double dereference when reading them
|
// Store a copy of these values to avoid double dereference when reading them
|
||||||
const SurfaceParams params;
|
const SurfaceParams surface_params;
|
||||||
const VkImage image;
|
const VkImage image;
|
||||||
const VkBufferView buffer_view;
|
const VkBufferView buffer_view;
|
||||||
const VkImageAspectFlags aspect_mask;
|
const VkImageAspectFlags aspect_mask;
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
VKUpdateDescriptorQueue::VKUpdateDescriptorQueue(const VKDevice& device, VKScheduler& scheduler)
|
VKUpdateDescriptorQueue::VKUpdateDescriptorQueue(const VKDevice& device_, VKScheduler& scheduler_)
|
||||||
: device{device}, scheduler{scheduler} {}
|
: device{device_}, scheduler{scheduler_} {}
|
||||||
|
|
||||||
VKUpdateDescriptorQueue::~VKUpdateDescriptorQueue() = default;
|
VKUpdateDescriptorQueue::~VKUpdateDescriptorQueue() = default;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct DescriptorUpdateEntry {
|
||||||
|
|
||||||
class VKUpdateDescriptorQueue final {
|
class VKUpdateDescriptorQueue final {
|
||||||
public:
|
public:
|
||||||
explicit VKUpdateDescriptorQueue(const VKDevice& device, VKScheduler& scheduler);
|
explicit VKUpdateDescriptorQueue(const VKDevice& device_, VKScheduler& scheduler_);
|
||||||
~VKUpdateDescriptorQueue();
|
~VKUpdateDescriptorQueue();
|
||||||
|
|
||||||
void TickFrame();
|
void TickFrame();
|
||||||
|
|
|
@ -417,7 +417,7 @@ VkResult Free(VkDevice device, VkCommandPool handle, Span<VkCommandBuffer> buffe
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance Instance::Create(u32 version, Span<const char*> layers, Span<const char*> extensions,
|
Instance Instance::Create(u32 version, Span<const char*> layers, Span<const char*> extensions,
|
||||||
InstanceDispatch& dld) noexcept {
|
InstanceDispatch& dispatch) noexcept {
|
||||||
const VkApplicationInfo application_info{
|
const VkApplicationInfo application_info{
|
||||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
|
@ -439,17 +439,17 @@ Instance Instance::Create(u32 version, Span<const char*> layers, Span<const char
|
||||||
};
|
};
|
||||||
|
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
if (dld.vkCreateInstance(&ci, nullptr, &instance) != VK_SUCCESS) {
|
if (dispatch.vkCreateInstance(&ci, nullptr, &instance) != VK_SUCCESS) {
|
||||||
// Failed to create the instance.
|
// Failed to create the instance.
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (!Proc(dld.vkDestroyInstance, dld, "vkDestroyInstance", instance)) {
|
if (!Proc(dispatch.vkDestroyInstance, dispatch, "vkDestroyInstance", instance)) {
|
||||||
// We successfully created an instance but the destroy function couldn't be loaded.
|
// We successfully created an instance but the destroy function couldn't be loaded.
|
||||||
// This is a good moment to panic.
|
// This is a good moment to panic.
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return Instance(instance, dld);
|
return Instance(instance, dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::vector<VkPhysicalDevice>> Instance::EnumeratePhysicalDevices() {
|
std::optional<std::vector<VkPhysicalDevice>> Instance::EnumeratePhysicalDevices() {
|
||||||
|
@ -540,7 +540,7 @@ std::vector<VkImage> SwapchainKHR::GetImages() const {
|
||||||
|
|
||||||
Device Device::Create(VkPhysicalDevice physical_device, Span<VkDeviceQueueCreateInfo> queues_ci,
|
Device Device::Create(VkPhysicalDevice physical_device, Span<VkDeviceQueueCreateInfo> queues_ci,
|
||||||
Span<const char*> enabled_extensions, const void* next,
|
Span<const char*> enabled_extensions, const void* next,
|
||||||
DeviceDispatch& dld) noexcept {
|
DeviceDispatch& dispatch) noexcept {
|
||||||
const VkDeviceCreateInfo ci{
|
const VkDeviceCreateInfo ci{
|
||||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||||
.pNext = next,
|
.pNext = next,
|
||||||
|
@ -555,11 +555,11 @@ Device Device::Create(VkPhysicalDevice physical_device, Span<VkDeviceQueueCreate
|
||||||
};
|
};
|
||||||
|
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
if (dld.vkCreateDevice(physical_device, &ci, nullptr, &device) != VK_SUCCESS) {
|
if (dispatch.vkCreateDevice(physical_device, &ci, nullptr, &device) != VK_SUCCESS) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
Load(device, dld);
|
Load(device, dispatch);
|
||||||
return Device(device, dld);
|
return Device(device, dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
Queue Device::GetQueue(u32 family_index) const noexcept {
|
Queue Device::GetQueue(u32 family_index) const noexcept {
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
|
|
||||||
/// Construct a span from a pointer and a size.
|
/// Construct a span from a pointer and a size.
|
||||||
/// This is inteded for subranges.
|
/// This is inteded for subranges.
|
||||||
constexpr Span(const T* ptr, std::size_t num) noexcept : ptr{ptr}, num{num} {}
|
constexpr Span(const T* ptr_, std::size_t num_) noexcept : ptr{ptr_}, num{num_} {}
|
||||||
|
|
||||||
/// Returns the data pointer by the span.
|
/// Returns the data pointer by the span.
|
||||||
constexpr const T* data() const noexcept {
|
constexpr const T* data() const noexcept {
|
||||||
|
@ -469,9 +469,10 @@ public:
|
||||||
PoolAllocations() = default;
|
PoolAllocations() = default;
|
||||||
|
|
||||||
/// Construct an allocation. Errors are reported through IsOutOfPoolMemory().
|
/// Construct an allocation. Errors are reported through IsOutOfPoolMemory().
|
||||||
explicit PoolAllocations(std::unique_ptr<AllocationType[]> allocations, std::size_t num,
|
explicit PoolAllocations(std::unique_ptr<AllocationType[]> allocations_, std::size_t num_,
|
||||||
VkDevice device, PoolType pool, const DeviceDispatch& dld) noexcept
|
VkDevice device_, PoolType pool_, const DeviceDispatch& dld_) noexcept
|
||||||
: allocations{std::move(allocations)}, num{num}, device{device}, pool{pool}, dld{&dld} {}
|
: allocations{std::move(allocations_)}, num{num_}, device{device_}, pool{pool_},
|
||||||
|
dld{&dld_} {}
|
||||||
|
|
||||||
/// Copying Vulkan allocations is not supported and will never be.
|
/// Copying Vulkan allocations is not supported and will never be.
|
||||||
PoolAllocations(const PoolAllocations&) = delete;
|
PoolAllocations(const PoolAllocations&) = delete;
|
||||||
|
@ -565,7 +566,7 @@ class Instance : public Handle<VkInstance, NoOwner, InstanceDispatch> {
|
||||||
public:
|
public:
|
||||||
/// Creates a Vulkan instance. Use "operator bool" for error handling.
|
/// Creates a Vulkan instance. Use "operator bool" for error handling.
|
||||||
static Instance Create(u32 version, Span<const char*> layers, Span<const char*> extensions,
|
static Instance Create(u32 version, Span<const char*> layers, Span<const char*> extensions,
|
||||||
InstanceDispatch& dld) noexcept;
|
InstanceDispatch& dispatch) noexcept;
|
||||||
|
|
||||||
/// Enumerates physical devices.
|
/// Enumerates physical devices.
|
||||||
/// @return Physical devices and an empty handle on failure.
|
/// @return Physical devices and an empty handle on failure.
|
||||||
|
@ -581,7 +582,8 @@ public:
|
||||||
constexpr Queue() noexcept = default;
|
constexpr Queue() noexcept = default;
|
||||||
|
|
||||||
/// Construct a queue handle.
|
/// Construct a queue handle.
|
||||||
constexpr Queue(VkQueue queue, const DeviceDispatch& dld) noexcept : queue{queue}, dld{&dld} {}
|
constexpr Queue(VkQueue queue_, const DeviceDispatch& dld_) noexcept
|
||||||
|
: queue{queue_}, dld{&dld_} {}
|
||||||
|
|
||||||
VkResult Submit(Span<VkSubmitInfo> submit_infos,
|
VkResult Submit(Span<VkSubmitInfo> submit_infos,
|
||||||
VkFence fence = VK_NULL_HANDLE) const noexcept {
|
VkFence fence = VK_NULL_HANDLE) const noexcept {
|
||||||
|
@ -720,7 +722,7 @@ class Device : public Handle<VkDevice, NoOwner, DeviceDispatch> {
|
||||||
public:
|
public:
|
||||||
static Device Create(VkPhysicalDevice physical_device, Span<VkDeviceQueueCreateInfo> queues_ci,
|
static Device Create(VkPhysicalDevice physical_device, Span<VkDeviceQueueCreateInfo> queues_ci,
|
||||||
Span<const char*> enabled_extensions, const void* next,
|
Span<const char*> enabled_extensions, const void* next,
|
||||||
DeviceDispatch& dld) noexcept;
|
DeviceDispatch& dispatch) noexcept;
|
||||||
|
|
||||||
Queue GetQueue(u32 family_index) const noexcept;
|
Queue GetQueue(u32 family_index) const noexcept;
|
||||||
|
|
||||||
|
@ -809,8 +811,9 @@ class PhysicalDevice {
|
||||||
public:
|
public:
|
||||||
constexpr PhysicalDevice() noexcept = default;
|
constexpr PhysicalDevice() noexcept = default;
|
||||||
|
|
||||||
constexpr PhysicalDevice(VkPhysicalDevice physical_device, const InstanceDispatch& dld) noexcept
|
constexpr PhysicalDevice(VkPhysicalDevice physical_device_,
|
||||||
: physical_device{physical_device}, dld{&dld} {}
|
const InstanceDispatch& dld_) noexcept
|
||||||
|
: physical_device{physical_device_}, dld{&dld_} {}
|
||||||
|
|
||||||
constexpr operator VkPhysicalDevice() const noexcept {
|
constexpr operator VkPhysicalDevice() const noexcept {
|
||||||
return physical_device;
|
return physical_device;
|
||||||
|
@ -849,8 +852,8 @@ class CommandBuffer {
|
||||||
public:
|
public:
|
||||||
CommandBuffer() noexcept = default;
|
CommandBuffer() noexcept = default;
|
||||||
|
|
||||||
explicit CommandBuffer(VkCommandBuffer handle, const DeviceDispatch& dld) noexcept
|
explicit CommandBuffer(VkCommandBuffer handle_, const DeviceDispatch& dld_) noexcept
|
||||||
: handle{handle}, dld{&dld} {}
|
: handle{handle_}, dld{&dld_} {}
|
||||||
|
|
||||||
const VkCommandBuffer* address() const noexcept {
|
const VkCommandBuffer* address() const noexcept {
|
||||||
return &handle;
|
return &handle;
|
||||||
|
|
|
@ -241,10 +241,10 @@ std::pair<ParseResult, ParseInfo> ParseCode(CFGRebuildState& state, u32 address)
|
||||||
ParseInfo parse_info{};
|
ParseInfo parse_info{};
|
||||||
SingleBranch single_branch{};
|
SingleBranch single_branch{};
|
||||||
|
|
||||||
const auto insert_label = [](CFGRebuildState& state, u32 address) {
|
const auto insert_label = [](CFGRebuildState& rebuild_state, u32 label_address) {
|
||||||
const auto pair = state.labels.emplace(address);
|
const auto pair = rebuild_state.labels.emplace(label_address);
|
||||||
if (pair.second) {
|
if (pair.second) {
|
||||||
state.inspect_queries.push_back(address);
|
rebuild_state.inspect_queries.push_back(label_address);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -358,9 +358,9 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
|
||||||
instr.suldst.GetStoreDataLayout() != StoreType::Bits64);
|
instr.suldst.GetStoreDataLayout() != StoreType::Bits64);
|
||||||
|
|
||||||
auto descriptor = [this, instr] {
|
auto descriptor = [this, instr] {
|
||||||
std::optional<Tegra::Engines::SamplerDescriptor> descriptor;
|
std::optional<Tegra::Engines::SamplerDescriptor> sampler_descriptor;
|
||||||
if (instr.suldst.is_immediate) {
|
if (instr.suldst.is_immediate) {
|
||||||
descriptor =
|
sampler_descriptor =
|
||||||
registry.ObtainBoundSampler(static_cast<u32>(instr.image.index.Value()));
|
registry.ObtainBoundSampler(static_cast<u32>(instr.image.index.Value()));
|
||||||
} else {
|
} else {
|
||||||
const Node image_register = GetRegister(instr.gpr39);
|
const Node image_register = GetRegister(instr.gpr39);
|
||||||
|
@ -368,12 +368,12 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
|
||||||
static_cast<s64>(global_code.size()));
|
static_cast<s64>(global_code.size()));
|
||||||
const auto buffer = std::get<1>(result);
|
const auto buffer = std::get<1>(result);
|
||||||
const auto offset = std::get<2>(result);
|
const auto offset = std::get<2>(result);
|
||||||
descriptor = registry.ObtainBindlessSampler(buffer, offset);
|
sampler_descriptor = registry.ObtainBindlessSampler(buffer, offset);
|
||||||
}
|
}
|
||||||
if (!descriptor) {
|
if (!sampler_descriptor) {
|
||||||
UNREACHABLE_MSG("Failed to obtain image descriptor");
|
UNREACHABLE_MSG("Failed to obtain image descriptor");
|
||||||
}
|
}
|
||||||
return *descriptor;
|
return *sampler_descriptor;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const auto comp_mask = GetImageComponentMask(descriptor.format);
|
const auto comp_mask = GetImageComponentMask(descriptor.format);
|
||||||
|
|
|
@ -90,11 +90,11 @@ u32 ShaderIR::DecodeOther(NodeBlock& bb, u32 pc) {
|
||||||
UNIMPLEMENTED_MSG("S2R WscaleFactorZ is not implemented");
|
UNIMPLEMENTED_MSG("S2R WscaleFactorZ is not implemented");
|
||||||
return Immediate(0U);
|
return Immediate(0U);
|
||||||
case SystemVariable::Tid: {
|
case SystemVariable::Tid: {
|
||||||
Node value = Immediate(0);
|
Node val = Immediate(0);
|
||||||
value = BitfieldInsert(value, Operation(OperationCode::LocalInvocationIdX), 0, 9);
|
val = BitfieldInsert(val, Operation(OperationCode::LocalInvocationIdX), 0, 9);
|
||||||
value = BitfieldInsert(value, Operation(OperationCode::LocalInvocationIdY), 16, 9);
|
val = BitfieldInsert(val, Operation(OperationCode::LocalInvocationIdY), 16, 9);
|
||||||
value = BitfieldInsert(value, Operation(OperationCode::LocalInvocationIdZ), 26, 5);
|
val = BitfieldInsert(val, Operation(OperationCode::LocalInvocationIdZ), 26, 5);
|
||||||
return value;
|
return val;
|
||||||
}
|
}
|
||||||
case SystemVariable::TidX:
|
case SystemVariable::TidX:
|
||||||
return Operation(OperationCode::LocalInvocationIdX);
|
return Operation(OperationCode::LocalInvocationIdX);
|
||||||
|
|
|
@ -167,27 +167,28 @@ std::vector<CopyParams> SurfaceBaseImpl::BreakDownNonLayered(const SurfaceParams
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceBaseImpl::SwizzleFunc(MortonSwizzleMode mode, u8* memory, const SurfaceParams& params,
|
void SurfaceBaseImpl::SwizzleFunc(MortonSwizzleMode mode, u8* memory,
|
||||||
u8* buffer, u32 level) {
|
const SurfaceParams& surface_params, u8* buffer, u32 level) {
|
||||||
const u32 width{params.GetMipWidth(level)};
|
const u32 width{surface_params.GetMipWidth(level)};
|
||||||
const u32 height{params.GetMipHeight(level)};
|
const u32 height{surface_params.GetMipHeight(level)};
|
||||||
const u32 block_height{params.GetMipBlockHeight(level)};
|
const u32 block_height{surface_params.GetMipBlockHeight(level)};
|
||||||
const u32 block_depth{params.GetMipBlockDepth(level)};
|
const u32 block_depth{surface_params.GetMipBlockDepth(level)};
|
||||||
|
|
||||||
std::size_t guest_offset{mipmap_offsets[level]};
|
std::size_t guest_offset{mipmap_offsets[level]};
|
||||||
if (params.is_layered) {
|
if (surface_params.is_layered) {
|
||||||
std::size_t host_offset = 0;
|
std::size_t host_offset = 0;
|
||||||
const std::size_t guest_stride = layer_size;
|
const std::size_t guest_stride = layer_size;
|
||||||
const std::size_t host_stride = params.GetHostLayerSize(level);
|
const std::size_t host_stride = surface_params.GetHostLayerSize(level);
|
||||||
for (u32 layer = 0; layer < params.depth; ++layer) {
|
for (u32 layer = 0; layer < surface_params.depth; ++layer) {
|
||||||
MortonSwizzle(mode, params.pixel_format, width, block_height, height, block_depth, 1,
|
MortonSwizzle(mode, surface_params.pixel_format, width, block_height, height,
|
||||||
params.tile_width_spacing, buffer + host_offset, memory + guest_offset);
|
block_depth, 1, surface_params.tile_width_spacing, buffer + host_offset,
|
||||||
|
memory + guest_offset);
|
||||||
guest_offset += guest_stride;
|
guest_offset += guest_stride;
|
||||||
host_offset += host_stride;
|
host_offset += host_stride;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MortonSwizzle(mode, params.pixel_format, width, block_height, height, block_depth,
|
MortonSwizzle(mode, surface_params.pixel_format, width, block_height, height, block_depth,
|
||||||
params.GetMipDepth(level), params.tile_width_spacing, buffer,
|
surface_params.GetMipDepth(level), surface_params.tile_width_spacing, buffer,
|
||||||
memory + guest_offset);
|
memory + guest_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,8 +167,8 @@ protected:
|
||||||
std::vector<std::size_t> mipmap_offsets;
|
std::vector<std::size_t> mipmap_offsets;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SwizzleFunc(MortonSwizzleMode mode, u8* memory, const SurfaceParams& params, u8* buffer,
|
void SwizzleFunc(MortonSwizzleMode mode, u8* memory, const SurfaceParams& surface_params,
|
||||||
u32 level);
|
u8* buffer, u32 level);
|
||||||
|
|
||||||
std::vector<CopyParams> BreakDownLayered(const SurfaceParams& in_params) const;
|
std::vector<CopyParams> BreakDownLayered(const SurfaceParams& in_params) const;
|
||||||
|
|
||||||
|
|
|
@ -356,18 +356,18 @@ std::size_t SurfaceParams::GetLayerSize(bool as_host_size, bool uncompressed) co
|
||||||
|
|
||||||
std::size_t SurfaceParams::GetInnerMipmapMemorySize(u32 level, bool as_host_size,
|
std::size_t SurfaceParams::GetInnerMipmapMemorySize(u32 level, bool as_host_size,
|
||||||
bool uncompressed) const {
|
bool uncompressed) const {
|
||||||
const u32 width{GetMipmapSize(uncompressed, GetMipWidth(level), GetDefaultBlockWidth())};
|
const u32 mip_width{GetMipmapSize(uncompressed, GetMipWidth(level), GetDefaultBlockWidth())};
|
||||||
const u32 height{GetMipmapSize(uncompressed, GetMipHeight(level), GetDefaultBlockHeight())};
|
const u32 mip_height{GetMipmapSize(uncompressed, GetMipHeight(level), GetDefaultBlockHeight())};
|
||||||
const u32 depth{is_layered ? 1U : GetMipDepth(level)};
|
const u32 mip_depth{is_layered ? 1U : GetMipDepth(level)};
|
||||||
if (is_tiled) {
|
if (is_tiled) {
|
||||||
return Tegra::Texture::CalculateSize(!as_host_size, GetBytesPerPixel(), width, height,
|
return Tegra::Texture::CalculateSize(!as_host_size, GetBytesPerPixel(), mip_width,
|
||||||
depth, GetMipBlockHeight(level),
|
mip_height, mip_depth, GetMipBlockHeight(level),
|
||||||
GetMipBlockDepth(level));
|
GetMipBlockDepth(level));
|
||||||
} else if (as_host_size || IsBuffer()) {
|
} else if (as_host_size || IsBuffer()) {
|
||||||
return GetBytesPerPixel() * width * height * depth;
|
return GetBytesPerPixel() * mip_width * mip_height * mip_depth;
|
||||||
} else {
|
} else {
|
||||||
// Linear Texture Case
|
// Linear Texture Case
|
||||||
return pitch * height * depth;
|
return pitch * mip_height * mip_depth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue