Cleanup 2/2

This commit is contained in:
Isuru Samarathunga
2025-11-05 16:23:50 +05:30
parent 7d6e8ef695
commit 80dc50d279
14 changed files with 275 additions and 74 deletions

View File

@ -24,7 +24,7 @@ namespace ia::iae
: (UINT32) 1)
{
SDL_GPUTextureCreateInfo createInfo{.type = SDL_GPU_TEXTURETYPE_2D,
.format = SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM,
.format = RDC_Device::GetSwapchainTextureFormat(),
.width = (UINT32) width,
.height = (UINT32) height,
.layer_count_or_depth = 1,
@ -54,6 +54,10 @@ namespace ia::iae
TMP_COLOR_BUFFER.resize(m_width * m_height * 4);
const auto swapchainFormat = RDC_Device::GetSwapchainTextureFormat();
const auto swapRB = (swapchainFormat == SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM) ||
(swapchainFormat == SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB);
if (stride == -1)
{
for (SIZE_T i = 0; i < TMP_COLOR_BUFFER.size() >> 2; i++)
@ -63,6 +67,9 @@ namespace ia::iae
TMP_COLOR_BUFFER[i * 4 + 1] = static_cast<UINT8>(rgbaData[i * 4 + 1] * a);
TMP_COLOR_BUFFER[i * 4 + 2] = static_cast<UINT8>(rgbaData[i * 4 + 2] * a);
TMP_COLOR_BUFFER[i * 4 + 3] = rgbaData[i * 4 + 3];
if (swapRB)
std::swap(TMP_COLOR_BUFFER[i * 4 + 0], TMP_COLOR_BUFFER[i * 4 + 2]);
}
}
else
@ -77,6 +84,9 @@ namespace ia::iae
TMP_COLOR_BUFFER[(x + y * m_width) * 4 + 1] = static_cast<UINT8>(p[1] * a);
TMP_COLOR_BUFFER[(x + y * m_width) * 4 + 2] = static_cast<UINT8>(p[2] * a);
TMP_COLOR_BUFFER[(x + y * m_width) * 4 + 3] = p[3];
if (swapRB)
std::swap(TMP_COLOR_BUFFER[(x + y * m_width) * 4 + 0],
TMP_COLOR_BUFFER[(x + y * m_width) * 4 + 0]);
}
}
}