[Misc] Replaced const with constexpr where possible

This commit is contained in:
Xphalnos
2025-04-04 22:36:05 +02:00
committed by Radosław Gliński
parent c4f1bf27ef
commit 47f327e848
42 changed files with 154 additions and 152 deletions

View File

@@ -306,7 +306,7 @@ class DeferredCommandBuffer {
void CmdVkSetScissor(uint32_t first_scissor, uint32_t scissor_count,
const VkRect2D* scissors) {
const size_t header_size =
constexpr size_t header_size =
xe::align(sizeof(ArgsVkSetScissor), alignof(VkRect2D));
uint8_t* args_ptr = reinterpret_cast<uint8_t*>(
WriteCommand(Command::kVkSetScissor,
@@ -345,7 +345,7 @@ class DeferredCommandBuffer {
void CmdVkSetViewport(uint32_t first_viewport, uint32_t viewport_count,
const VkViewport* viewports) {
const size_t header_size =
constexpr size_t header_size =
xe::align(sizeof(ArgsVkSetViewport), alignof(VkViewport));
uint8_t* args_ptr = reinterpret_cast<uint8_t*>(
WriteCommand(Command::kVkSetViewport,

View File

@@ -54,18 +54,18 @@ namespace shaders {
#include "xenia/gpu/shaders/bytecode/vulkan_spirv/fullscreen_cw_vs.h"
} // namespace shaders
const VkDescriptorPoolSize
constexpr VkDescriptorPoolSize
VulkanCommandProcessor::kDescriptorPoolSizeUniformBuffer = {
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
SpirvShaderTranslator::kConstantBufferCount*
kLinkedTypeDescriptorPoolSetCount};
const VkDescriptorPoolSize
constexpr VkDescriptorPoolSize
VulkanCommandProcessor::kDescriptorPoolSizeStorageBuffer = {
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, kLinkedTypeDescriptorPoolSetCount};
// 2x descriptors for texture images because of unsigned and signed bindings.
const VkDescriptorPoolSize
constexpr VkDescriptorPoolSize
VulkanCommandProcessor::kDescriptorPoolSizeTextures[2] = {
{VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
2 * kLinkedTypeDescriptorPoolSetCount},

View File

@@ -442,7 +442,7 @@ void VulkanPipelineCache::WritePipelineRenderTargetDescription(
if (write_mask) {
assert_zero(write_mask & ~uint32_t(0b1111));
// 32 because of 0x1F mask, for safety (all unknown to zero).
static const PipelineBlendFactor kBlendFactorMap[32] = {
static constexpr PipelineBlendFactor kBlendFactorMap[32] = {
/* 0 */ PipelineBlendFactor::kZero,
/* 1 */ PipelineBlendFactor::kOne,
/* 2 */ PipelineBlendFactor::kZero, // ?

View File

@@ -88,7 +88,7 @@ namespace shaders {
static_assert(VK_FORMAT_UNDEFINED == VkFormat(0),
"Assuming that skipping a VkFormat in an initializer results in "
"VK_FORMAT_UNDEFINED");
const VulkanTextureCache::HostFormatPair
constexpr VulkanTextureCache::HostFormatPair
VulkanTextureCache::kBestHostFormats[64] = {
// k_1_REVERSE
{{kLoadShaderIndexUnknown},
@@ -408,14 +408,14 @@ const VulkanTextureCache::HostFormatPair
// Always decompressing them to RGBA8, which is required to be linear-filterable
// as UNORM and SNORM.
const VulkanTextureCache::HostFormatPair
constexpr VulkanTextureCache::HostFormatPair
VulkanTextureCache::kHostFormatGBGRUnaligned = {
{kLoadShaderIndexGBGR8ToRGB8, VK_FORMAT_R8G8B8A8_UNORM, false, true},
{kLoadShaderIndexGBGR8ToRGB8, VK_FORMAT_R8G8B8A8_SNORM, false, true},
xenos::XE_GPU_TEXTURE_SWIZZLE_RGBB,
true};
const VulkanTextureCache::HostFormatPair
constexpr VulkanTextureCache::HostFormatPair
VulkanTextureCache::kHostFormatBGRGUnaligned = {
{kLoadShaderIndexBGRG8ToRGB8, VK_FORMAT_R8G8B8A8_UNORM, false, true},
{kLoadShaderIndexBGRG8ToRGB8, VK_FORMAT_R8G8B8A8_SNORM, false, true},