mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-21 03:54:45 +00:00
review comments
This commit is contained in:
parent
f3338e7080
commit
5a6d8878ae
5 changed files with 14 additions and 22 deletions
|
@ -254,7 +254,6 @@ set(COMMON src/common/logging/backend.cpp
|
|||
src/common/error.h
|
||||
src/common/scope_exit.h
|
||||
src/common/func_traits.h
|
||||
src/common/math.h
|
||||
src/common/native_clock.cpp
|
||||
src/common/native_clock.h
|
||||
src/common/path_util.cpp
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/types.h"
|
||||
|
||||
static inline u32 IntLog2(u32 i) {
|
||||
return 31u - __builtin_clz(i | 1u);
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
#include <boost/container/static_vector.hpp>
|
||||
#include <fmt/format.h>
|
||||
|
||||
static constexpr auto M_PI = 3.14159265358979323846f;
|
||||
#include <numbers>
|
||||
|
||||
namespace Shader::Backend::SPIRV {
|
||||
namespace {
|
||||
|
@ -103,7 +103,7 @@ void EmitContext::DefineArithmeticTypes() {
|
|||
u32_zero_value = ConstU32(0U);
|
||||
f32_zero_value = ConstF32(0.0f);
|
||||
|
||||
pi_x2 = ConstF32(2.0f * float(M_PI));
|
||||
pi_x2 = ConstF32(2.0f * float{std::numbers::pi});
|
||||
|
||||
input_f32 = Name(TypePointer(spv::StorageClass::Input, F32[1]), "input_f32");
|
||||
input_u32 = Name(TypePointer(spv::StorageClass::Input, U32[1]), "input_u32");
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "common/assert.h"
|
||||
#include "common/config.h"
|
||||
#include "common/math.h"
|
||||
#include "video_core/renderer_vulkan/liverpool_to_vk.h"
|
||||
#include "video_core/texture_cache/image_info.h"
|
||||
|
||||
|
@ -46,6 +45,7 @@ static vk::ImageType ConvertImageType(AmdGpu::ImageType type) noexcept {
|
|||
}
|
||||
|
||||
// clang-format off
|
||||
// The table of macro tiles parameters for given tiling index (row) and bpp (column)
|
||||
static constexpr std::array macro_tile_extents{
|
||||
std::pair{256u, 128u}, std::pair{256u, 128u}, std::pair{256u, 128u}, std::pair{256u, 128u}, // 00
|
||||
std::pair{256u, 128u}, std::pair{128u, 128u}, std::pair{128u, 128u}, std::pair{128u, 128u}, // 01
|
||||
|
@ -77,9 +77,14 @@ static constexpr std::array macro_tile_extents{
|
|||
};
|
||||
// clang-format on
|
||||
|
||||
static constexpr std::pair micro_tile_extent{8u, 8u};
|
||||
static constexpr auto hw_pipe_interleave = 256u;
|
||||
|
||||
static constexpr std::pair<u32, u32> GetMacroTileExtents(u32 tiling_idx, u32 bpp, u32 num_samples) {
|
||||
ASSERT(num_samples == 1);
|
||||
return macro_tile_extents[tiling_idx * 4 + IntLog2(bpp) - 3];
|
||||
const auto row = tiling_idx * 4;
|
||||
const auto column = std::bit_width(bpp) - 4; // bpps are 8, 16, 32, 64
|
||||
return macro_tile_extents[row + column];
|
||||
}
|
||||
|
||||
static constexpr size_t ImageSizeLinearAligned(u32 pitch, u32 height, u32 bpp, u32 num_samples) {
|
||||
|
@ -87,7 +92,7 @@ static constexpr size_t ImageSizeLinearAligned(u32 pitch, u32 height, u32 bpp, u
|
|||
auto pitch_aligned = (pitch + pitch_align - 1) & ~(pitch_align - 1);
|
||||
const auto height_aligned = height;
|
||||
size_t log_sz = 1;
|
||||
const auto slice_align = std::max(64u, 256u / (bpp + 7) / 8);
|
||||
const auto slice_align = std::max(64u, hw_pipe_interleave / (bpp + 7) / 8);
|
||||
while (log_sz % slice_align) {
|
||||
log_sz = pitch_aligned * height_aligned * num_samples;
|
||||
pitch_aligned += pitch_align;
|
||||
|
@ -96,8 +101,7 @@ static constexpr size_t ImageSizeLinearAligned(u32 pitch, u32 height, u32 bpp, u
|
|||
}
|
||||
|
||||
static constexpr size_t ImageSizeMicroTiled(u32 pitch, u32 height, u32 bpp, u32 num_samples) {
|
||||
const auto pitch_align = 8u;
|
||||
const auto height_align = 8u;
|
||||
const auto& [pitch_align, height_align] = micro_tile_extent;
|
||||
auto pitch_aligned = (pitch + pitch_align - 1) & ~(pitch_align - 1);
|
||||
const auto height_aligned = (height + height_align - 1) & ~(height_align - 1);
|
||||
size_t log_sz = 1;
|
||||
|
@ -193,7 +197,7 @@ ImageInfo::ImageInfo(const AmdGpu::Image& image) noexcept {
|
|||
pixel_format = LiverpoolToVK::SurfaceFormat(image.GetDataFmt(), image.GetNumberFmt());
|
||||
type = ConvertImageType(image.GetType());
|
||||
is_cube = image.GetType() == AmdGpu::ImageType::Cube;
|
||||
const auto is_volume = image.GetType() == AmdGpu::ImageType::Color3D;
|
||||
is_volume = image.GetType() == AmdGpu::ImageType::Color3D;
|
||||
size.width = image.width + 1;
|
||||
size.height = image.height + 1;
|
||||
size.depth = is_volume ? image.depth + 1 : 1;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/math.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
||||
#include "video_core/renderer_vulkan/vk_shader_util.h"
|
||||
|
@ -78,8 +77,8 @@ public:
|
|||
|
||||
static u32 getBankIdx(u32 x, u32 y, u32 bank_width, u32 bank_height, u32 num_banks,
|
||||
u32 num_pipes) {
|
||||
const u32 x_shift_offset = IntLog2(bank_width * num_pipes);
|
||||
const u32 y_shift_offset = IntLog2(bank_height);
|
||||
const u32 x_shift_offset = std::bit_width(bank_width * num_pipes) - 1;
|
||||
const u32 y_shift_offset = std::bit_width(bank_height) - 1;
|
||||
const u32 xs = x >> x_shift_offset;
|
||||
const u32 ys = y >> y_shift_offset;
|
||||
u32 bank = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue