Skip to content

Adding a lot of constexpr #1521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if (MACOS_BUNDLE)
set(MACOSX_BUNDLE_BUNDLE_NAME "Cemu")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${EMULATOR_VERSION_MAJOR}.${EMULATOR_VERSION_MINOR}.${EMULATOR_VERSION_PATCH}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${EMULATOR_VERSION_MAJOR}.${EMULATOR_VERSION_MINOR}.${EMULATOR_VERSION_PATCH}")
set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2024 Cemu Project")
set(MACOSX_BUNDLE_COPYRIGHT "Copyright © 2025 Cemu Project")

set(MACOSX_BUNDLE_CATEGORY "public.app-category.games")
set(MACOSX_MINIMUM_SYSTEM_VERSION "12.0")
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/CafeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void LoadMainExecutable()
}
currentUpdatedApplicationHash = generateHashFromRawRPXData(rpxData, rpxSize);
// determine if this file is an ELF
const uint8 elfHeaderMagic[9] = { 0x7F,0x45,0x4C,0x46,0x01,0x02,0x01,0x00,0x00 };
constexpr uint8 elfHeaderMagic[9] = { 0x7F,0x45,0x4C,0x46,0x01,0x02,0x01,0x00,0x00 };
if (rpxSize >= 10 && memcmp(rpxData, elfHeaderMagic, sizeof(elfHeaderMagic)) == 0)
{
// ELF
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/GameProfile/GameProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GameProfile
friend class GameProfileWindow;

public:
static const uint32 kThreadQuantumDefault = 45000;
static constexpr uint32 kThreadQuantumDefault = 45000;

bool Load(uint64_t title_id);
void Save(uint64_t title_id);
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/GraphicPack/GraphicPack2PatchesParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void GraphicPack2::ParseCemuhookPatchesTxtInternal(MemStreamReader& patchesStrea
AddPatchGroup(currentGroup);
}

static inline uint32 INVALID_ORIGIN = 0xFFFFFFFF;
static constexpr inline uint32 INVALID_ORIGIN = 0xFFFFFFFF;

bool GraphicPack2::ParseCemuPatchesTxtInternal(MemStreamReader& patchesStream)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Cafe/HW/Espresso/Interpreter/PPCInterpreterFPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <limits>
#include <array>

const int ieee_double_e_bits = 11; // exponent bits
const int ieee_double_m_bits = 52; // mantissa bits
constexpr int ieee_double_e_bits = 11; // exponent bits
constexpr int ieee_double_m_bits = 52; // mantissa bits

const int espresso_frsqrte_i_bits = 5; // index bits (the highest bit is the LSB of the exponent)
constexpr int espresso_frsqrte_i_bits = 5; // index bits (the highest bit is the LSB of the exponent)

typedef struct
{
Expand Down Expand Up @@ -89,8 +89,8 @@ double frsqrte_espresso(double input)
return *(double*)&x;
}

const int espresso_fres_i_bits = 5; // index bits
const int espresso_fres_s_bits = 10; // step multiplier bits
constexpr int espresso_fres_i_bits = 5; // index bits
constexpr int espresso_fres_s_bits = 10; // step multiplier bits

typedef struct
{
Expand Down
4 changes: 2 additions & 2 deletions src/Cafe/HW/Espresso/Interpreter/PPCInterpreterHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static inline bool ppc_carry_3(uint32 a, uint32 b, uint32 c)

#define PPC_getBits(__value, __index, __bitCount) ((__value>>(31-__index))&((1<<__bitCount)-1))

const static float LD_SCALE[] = {
constexpr static float LD_SCALE[] = {
1.000000f, 0.500000f, 0.250000f, 0.125000f, 0.062500f, 0.031250f, 0.015625f,
0.007813f, 0.003906f, 0.001953f, 0.000977f, 0.000488f, 0.000244f, 0.000122f,
0.000061f, 0.000031f, 0.000015f, 0.000008f, 0.000004f, 0.000002f, 0.000001f,
Expand All @@ -46,7 +46,7 @@ const static float LD_SCALE[] = {
8192.000000f, 4096.000000f, 2048.000000f, 1024.000000f, 512.000000f, 256.000000f, 128.000000f, 64.000000f, 32.000000f,
16.000000f, 8.000000f, 4.000000f, 2.000000f };

const static float ST_SCALE[] = {
constexpr static float ST_SCALE[] = {
1.000000f, 2.000000f, 4.000000f, 8.000000f,
16.000000f, 32.000000f, 64.000000f, 128.000000f,
256.000000f, 512.000000f, 1024.000000f, 2048.000000f,
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/Common/RegisterSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ RunAtCemuBoot _loadPipelineCompressionDictionary([]()
Latte::UnitTestPipelineSerialization();
});

const uint8 s_regDataDict[] = // 0x5AD2 Uncompressed: 0x1B800
constexpr uint8 s_regDataDict[] = // 0x5AD2 Uncompressed: 0x1B800
{
0x28, 0xB5, 0x2F, 0xFD, 0xA4, 0x00, 0xB8, 0x01, 0x00, 0x15, 0xD6, 0x02,
0xFA, 0x09, 0x2B, 0xA7, 0x4C, 0x10, 0x10, 0x4A, 0xE9, 0xB4, 0x06, 0xCA,
Expand Down
8 changes: 4 additions & 4 deletions src/Cafe/HW/Latte/Core/LatteBufferCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,10 @@ class BufferCacheNode

static uint64 hashPage(uint8* mem)
{
static const uint64 k0 = 0x55F23EAD;
static const uint64 k1 = 0x185FDC6D;
static const uint64 k2 = 0xF7431F49;
static const uint64 k3 = 0xA4C7AE9D;
static constexpr uint64 k0 = 0x55F23EAD;
static constexpr uint64 k1 = 0x185FDC6D;
static constexpr uint64 k2 = 0xF7431F49;
static constexpr uint64 k3 = 0xA4C7AE9D;

cemu_assert_debug((CACHE_PAGE_SIZE % 32) == 0);
const uint64* ptr = (const uint64*)mem;
Expand Down
16 changes: 8 additions & 8 deletions src/Cafe/HW/Latte/Core/LatteCommandProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,14 @@ LatteCMDPtr LatteCP_itWaitRegMem(LatteCMDPtr cmd, uint32 nWords)

uint32* fencePtr = (uint32*)memory_getPointerFromPhysicalOffset(physAddr);

const uint32 GPU7_WAIT_MEM_OP_ALWAYS = 0;
const uint32 GPU7_WAIT_MEM_OP_LESS = 1;
const uint32 GPU7_WAIT_MEM_OP_LEQUAL = 2;
const uint32 GPU7_WAIT_MEM_OP_EQUAL = 3;
const uint32 GPU7_WAIT_MEM_OP_NOTEQUAL = 4;
const uint32 GPU7_WAIT_MEM_OP_GEQUAL = 5;
const uint32 GPU7_WAIT_MEM_OP_GREATER = 6;
const uint32 GPU7_WAIT_MEM_OP_NEVER = 7;
constexpr uint32 GPU7_WAIT_MEM_OP_ALWAYS = 0;
constexpr uint32 GPU7_WAIT_MEM_OP_LESS = 1;
constexpr uint32 GPU7_WAIT_MEM_OP_LEQUAL = 2;
constexpr uint32 GPU7_WAIT_MEM_OP_EQUAL = 3;
constexpr uint32 GPU7_WAIT_MEM_OP_NOTEQUAL = 4;
constexpr uint32 GPU7_WAIT_MEM_OP_GEQUAL = 5;
constexpr uint32 GPU7_WAIT_MEM_OP_GREATER = 6;
constexpr uint32 GPU7_WAIT_MEM_OP_NEVER = 7;

LatteCP_signalEnterWait();

Expand Down
4 changes: 2 additions & 2 deletions src/Cafe/HW/Latte/Core/LatteOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ struct OverlayList
: text(std::move(text)), width(width) {}
};

const auto kPopupFlags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
constexpr auto kPopupFlags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;

const float kBackgroundAlpha = 0.65f;
constexpr float kBackgroundAlpha = 0.65f;
void LatteOverlay_renderOverlay(ImVec2& position, ImVec2& pivot, sint32 direction, float fontSize, bool pad)
{
auto& config = GetConfig();
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ bool LatteMRT::GetActiveDepthBufferMask(const LatteContextRegister& lcr)
return depthBufferMask;
}

const uint32 _colorBufferFormatBits[] =
constexpr uint32 _colorBufferFormatBits[] =
{
0, // 0
0x200, // 1
Expand Down
10 changes: 5 additions & 5 deletions src/Cafe/HW/Latte/Core/LatteShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,22 +281,22 @@ void LatteShaderCache_finish()
uint32 LatteShaderCache_getShaderCacheExtraVersion(uint64 titleId)
{
// encode the titleId in the version to prevent users from swapping caches between titles
const uint32 cacheFileVersion = 1;
constexpr uint32 cacheFileVersion = 1;
uint32 extraVersion = ((uint32)(titleId >> 32) + ((uint32)titleId) * 3) + cacheFileVersion + 0xe97af1ad;
return extraVersion;
}

uint32 LatteShaderCache_getPipelineCacheExtraVersion(uint64 titleId)
{
const uint32 cacheFileVersion = 1;
constexpr uint32 cacheFileVersion = 1;
uint32 extraVersion = ((uint32)(titleId >> 32) + ((uint32)titleId) * 3) + cacheFileVersion;
return extraVersion;
}

void LatteShaderCache_drawBackgroundImage(ImTextureID texture, int width, int height)
{
// clear framebuffers and clean up
const auto kPopupFlags =
constexpr auto kPopupFlags =
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoBringToFrontOnFocus;
Expand Down Expand Up @@ -492,8 +492,8 @@ void LatteShaderCache_Load()

void LatteShaderCache_ShowProgress(const std::function <bool(void)>& loadUpdateFunc, bool isPipelines)
{
const auto kPopupFlags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize;
const auto textColor = 0xFF888888;
constexpr auto kPopupFlags = ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_AlwaysAutoResize;
constexpr auto textColor = 0xFF888888;

auto lastFrameUpdate = tick_cached();

Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/ISA/LatteReg.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ namespace Latte

inline uint32 GetFormatBits(const Latte::E_HWSURFFMT hwFmt)
{
const uint8 sBitsTable[0x40] = {
constexpr uint8 sBitsTable[0x40] = {
0x00,0x08,0x08,0x00,0x00,0x10,0x10,0x10,
0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x20,
0x20,0x20,0x00,0x20,0x00,0x00,0x20,0x00,
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace LatteAddrLib
BAD_SIZE_FIELD = 6,
};

const uint32 m_configFlags = (1 << 29);
constexpr uint32 m_configFlags = (1 << 29);

uint32 GetSliceComputingFlags()
{
Expand Down
20 changes: 10 additions & 10 deletions src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

namespace LatteAddrLib
{
static const uint32 m_banks = 4;
static const uint32 m_banksBitcount = 2;
static const uint32 m_pipes = 2;
static const uint32 m_pipesBitcount = 1;
static const uint32 m_pipeInterleaveBytes = 256;
static const uint32 m_pipeInterleaveBytesBitcount = 8;
static const uint32 m_rowSize = 2048;
static const uint32 m_swapSize = 256;
static const uint32 m_splitSize = 2048;
static const uint32 m_chipFamily = 2;
static constexpr uint32 m_banks = 4;
static constexpr uint32 m_banksBitcount = 2;
static constexpr uint32 m_pipes = 2;
static constexpr uint32 m_pipesBitcount = 1;
static constexpr uint32 m_pipeInterleaveBytes = 256;
static constexpr uint32 m_pipeInterleaveBytesBitcount = 8;
static constexpr uint32 m_rowSize = 2048;
static constexpr uint32 m_swapSize = 256;
static constexpr uint32 m_splitSize = 2048;
static constexpr uint32 m_chipFamily = 2;

union AddrSurfaceFlags
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/LatteAddrLib/LatteAddrLib_Coord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace LatteAddrLib
}
#endif

static const uint32 bankSwapOrder[] = { 0, 1, 3, 2 };
static constexpr uint32 bankSwapOrder[] = { 0, 1, 3, 2 };

uint32 _GetMicroTileType(bool isDepth)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct LatteDecompilerShaderResourceMapping
std::fill(uniformBuffersBindingPoint, uniformBuffersBindingPoint + LATTE_NUM_MAX_UNIFORM_BUFFERS, -1);
std::fill(attributeMapping, attributeMapping + LATTE_NUM_MAX_ATTRIBUTE_LOCATIONS, -1);
}
static const sint8 UNUSED_BINDING = -1;
static constexpr sint8 UNUSED_BINDING = -1;
// most of this is for Vulkan
sint8 setIndex{};
// texture
Expand Down
10 changes: 5 additions & 5 deletions src/Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace CemuGL
#include "config/ActiveSettings.h"
#include "config/LaunchSettings.h"

static const int TEXBUFFER_SIZE = 1024 * 1024 * 32; // 32MB
static constexpr int TEXBUFFER_SIZE = 1024 * 1024 * 32; // 32MB

struct
{
Expand All @@ -56,7 +56,7 @@ struct
GLuint clearFBO;
}glRendererState;

static const GLenum glDepthFuncTable[] =
static constexpr GLenum glDepthFuncTable[] =
{
GL_NEVER,
GL_LESS,
Expand All @@ -68,7 +68,7 @@ static const GLenum glDepthFuncTable[] =
GL_ALWAYS
};

static const GLenum glAlphaTestFunc[] =
static constexpr GLenum glAlphaTestFunc[] =
{
GL_NEVER,
GL_LESS,
Expand Down Expand Up @@ -728,7 +728,7 @@ void OpenGLRenderer::renderstate_setAlwaysWriteDepth()
prevDepthFunc = Latte::LATTE_DB_DEPTH_CONTROL::E_ZFUNC::ALWAYS;
}

static const GLuint table_glBlendSrcDst[] =
static constexpr GLuint table_glBlendSrcDst[] =
{
/* 0x00 */ GL_ZERO,
/* 0x01 */ GL_ONE,
Expand Down Expand Up @@ -776,7 +776,7 @@ static GLuint GetGLBlendFactor(Latte::LATTE_CB_BLENDN_CONTROL::E_BLENDFACTOR ble
return table_glBlendSrcDst[blendFactorU];
}

static const GLuint table_glBlendCombine[] =
static constexpr GLuint table_glBlendCombine[] =
{
GL_FUNC_ADD,
GL_FUNC_SUBTRACT,
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ VKRObjectTextureView* LatteTextureViewVk::CreateView(uint32 gpuSamplerSwizzle)
viewInfo.subresourceRange.layerCount = this->numSlice;
}

static const VkComponentSwizzle swizzle[] =
static constexpr VkComponentSwizzle swizzle[] =
{
VK_COMPONENT_SWIZZLE_R,
VK_COMPONENT_SWIZZLE_G,
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/Renderer/Vulkan/LatteTextureViewVk.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LatteTextureViewVk : public LatteTextureView
// each texture view holds one Vulkan image view per swizzle mask. Image views are only instantiated when requested via GetViewRGBA/GetSamplerView
// since a large majority of texture views will only have 1 or 2 instantiated image views, we use a small fixed-size cache
// and only allocate the larger map (m_fallbackCache) if necessary
inline static const uint32 CACHE_EMPTY_ENTRY = 0xFFFFFFFF;
inline static constexpr uint32 CACHE_EMPTY_ENTRY = 0xFFFFFFFF;

uint32 m_smallCacheSwizzle0 = { CACHE_EMPTY_ENTRY };
uint32 m_smallCacheSwizzle1 = { CACHE_EMPTY_ENTRY };
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Latte/Renderer/Vulkan/RendererShaderVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class _ShaderVkThreadPool
if (m_threadsActive.exchange(true))
return;
// create thread pool
const uint32 threadCount = 2;
constexpr uint32 threadCount = 2;
for (uint32 i = 0; i < threadCount; ++i)
s_threads.emplace_back(&_ShaderVkThreadPool::CompilerThreadFunc, this);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Cafe/HW/Latte/Renderer/Vulkan/VulkanPipelineCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static VkBlendOp GetVkBlendOp(Latte::LATTE_CB_BLENDN_CONTROL::E_COMBINEFUNC comb

static VkBlendFactor GetVkBlendFactor(Latte::LATTE_CB_BLENDN_CONTROL::E_BLENDFACTOR factor)
{
const VkBlendFactor factors[] =
constexpr VkBlendFactor factors[] =
{
/* 0x00 */ VK_BLEND_FACTOR_ZERO,
/* 0x01 */ VK_BLEND_FACTOR_ONE,
Expand Down Expand Up @@ -774,7 +774,7 @@ void PipelineCompiler::InitDepthStencilState()
depthStencilState.depthTestEnable = depthEnable ? VK_TRUE : VK_FALSE;
depthStencilState.depthWriteEnable = depthWriteEnable ? VK_TRUE : VK_FALSE;

static const VkCompareOp vkDepthCompareTable[8] =
static constexpr VkCompareOp vkDepthCompareTable[8] =
{
VK_COMPARE_OP_NEVER,
VK_COMPARE_OP_LESS,
Expand Down Expand Up @@ -811,7 +811,7 @@ void PipelineCompiler::InitDepthStencilState()
uint32 stencilWriteMaskBack = LatteGPUState.contextNew.DB_STENCILREFMASK_BF.get_STENCILWRITEMASK_B();
uint32 stencilRefBack = LatteGPUState.contextNew.DB_STENCILREFMASK_BF.get_STENCILREF_B();

static const VkStencilOp stencilOpTable[8] = {
static constexpr VkStencilOp stencilOpTable[8] = {
VK_STENCIL_OP_KEEP,
VK_STENCIL_OP_ZERO,
VK_STENCIL_OP_REPLACE,
Expand Down
8 changes: 4 additions & 4 deletions src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

extern std::atomic_int g_compiling_pipelines;

const std::vector<const char*> kOptionalDeviceExtensions =
const std::vector<const char*> kOptionalDeviceExtensions =
{
VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME,
VK_NV_FILL_RECTANGLE_EXTENSION_NAME,
Expand Down Expand Up @@ -1074,7 +1074,7 @@ void VulkanRenderer::HandleScreenshotRequest(LatteTextureView* texView, bool pad
SaveScreenshot(rgb_data, width, height, !padView);
}

static const float kQueuePriority = 1.0f;
static constexpr float kQueuePriority = 1.0f;

std::vector<VkDeviceQueueCreateInfo> VulkanRenderer::CreateQueueCreateInfos(const std::set<sint32>& uniqueQueueFamilies) const
{
Expand Down Expand Up @@ -2000,7 +2000,7 @@ void VulkanRenderer::SubmitCommandBuffer(VkSemaphore signalSemaphore, VkSemaphor

// wait for previous command buffer semaphore
VkSemaphore prevSem = GetLastSubmittedCmdBufferSemaphore();
const VkPipelineStageFlags semWaitStageMask[2] = { VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT };
constexpr VkPipelineStageFlags semWaitStageMask[2] = { VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT };
VkSemaphore waitSemArray[2];
submitInfo.waitSemaphoreCount = 0;
if (m_numSubmittedCmdBuffers > 0)
Expand Down Expand Up @@ -3512,7 +3512,7 @@ LatteTextureReadbackInfo* VulkanRenderer::texture_createReadback(LatteTextureVie

const uint32 linearImageSize = result->GetImageSize();
const uint32 uploadSize = (linearImageSize == 0) ? memRequirements.size : linearImageSize;
const uint32 uploadAlignment = 256; // todo - use Vk optimalBufferCopyOffsetAlignment
constexpr uint32 uploadAlignment = 256; // todo - use Vk optimalBufferCopyOffsetAlignment
m_textureReadbackBufferWriteIndex = (m_textureReadbackBufferWriteIndex + uploadAlignment - 1) & ~(uploadAlignment - 1);

if ((m_textureReadbackBufferWriteIndex + uploadSize + 256) > TEXTURE_READBACK_SIZE)
Expand Down
Loading
Loading