summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar FernandoS272021-10-19 19:41:57 +0200
committerGravatar Fernando Sahmkow2021-11-16 22:11:31 +0100
commit826a350e2b6aadb4f123189c28f065b0e7926264 (patch)
tree313ea78b62cee597b3c6f36ff2ca2bd37f29319d /src
parentTexture cache: fix Intel with rescaler. (diff)
downloadyuzu-826a350e2b6aadb4f123189c28f065b0e7926264.tar.gz
yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.tar.xz
yuzu-826a350e2b6aadb4f123189c28f065b0e7926264.zip
Vulkan Rasterizer: Fix clears on integer textures.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp34
-rw-r--r--src/video_core/surface.cpp47
-rw-r--r--src/video_core/surface.h4
3 files changed, 84 insertions, 1 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index a9334e101..ff75d14a1 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -211,6 +211,8 @@ void RasterizerVulkan::Draw(bool is_indexed, bool is_instanced) {
211 EndTransformFeedback(); 211 EndTransformFeedback();
212} 212}
213 213
214#pragma optimize("", off)
215
214void RasterizerVulkan::Clear() { 216void RasterizerVulkan::Clear() {
215 MICROPROFILE_SCOPE(Vulkan_Clearing); 217 MICROPROFILE_SCOPE(Vulkan_Clearing);
216 218
@@ -260,7 +262,37 @@ void RasterizerVulkan::Clear() {
260 const u32 color_attachment = regs.clear_buffers.RT; 262 const u32 color_attachment = regs.clear_buffers.RT;
261 if (use_color && framebuffer->HasAspectColorBit(color_attachment)) { 263 if (use_color && framebuffer->HasAspectColorBit(color_attachment)) {
262 VkClearValue clear_value; 264 VkClearValue clear_value;
263 std::memcpy(clear_value.color.float32, regs.clear_color, sizeof(regs.clear_color)); 265 bool is_integer = false;
266 bool is_signed = false;
267 size_t int_size = 8;
268 for (std::size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; ++i) {
269 const auto& this_rt = regs.rt[i];
270 if (this_rt.Address() == 0) {
271 continue;
272 }
273 if (this_rt.format == Tegra::RenderTargetFormat::NONE) {
274 continue;
275 }
276 const auto format =
277 VideoCore::Surface::PixelFormatFromRenderTargetFormat(this_rt.format);
278 is_integer = IsPixelFormatInteger(format);
279 is_signed = IsPixelFormatSignedInteger(format);
280 int_size = PixelComponentSizeBitsInteger(format);
281 break;
282 }
283 if (!is_integer) {
284 std::memcpy(clear_value.color.float32, regs.clear_color, sizeof(regs.clear_color));
285 } else if (!is_signed) {
286 for (size_t i = 0; i < 4; i++) {
287 clear_value.color.uint32[i] =
288 static_cast<u32>(static_cast<u64>(int_size << 1U) * regs.clear_color[i]);
289 }
290 } else {
291 for (size_t i = 0; i < 4; i++) {
292 clear_value.color.int32[i] = static_cast<s32>(
293 (static_cast<s32>(int_size - 1) << 1) * (regs.clear_color[i] - 0.5f));
294 }
295 }
264 296
265 scheduler.Record([color_attachment, clear_value, clear_rect](vk::CommandBuffer cmdbuf) { 297 scheduler.Record([color_attachment, clear_value, clear_rect](vk::CommandBuffer cmdbuf) {
266 const VkClearAttachment attachment{ 298 const VkClearAttachment attachment{
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index 64941a486..58d262446 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -306,6 +306,53 @@ bool IsPixelFormatInteger(PixelFormat format) {
306 } 306 }
307} 307}
308 308
309bool IsPixelFormatSignedInteger(PixelFormat format) {
310 switch (format) {
311 case PixelFormat::A8B8G8R8_SINT:
312 case PixelFormat::R8_SINT:
313 case PixelFormat::R16G16B16A16_SINT:
314 case PixelFormat::R32G32B32A32_SINT:
315 case PixelFormat::R32G32_SINT:
316 case PixelFormat::R16_SINT:
317 case PixelFormat::R16G16_SINT:
318 case PixelFormat::R8G8_SINT:
319 case PixelFormat::R32_SINT:
320 return true;
321 default:
322 return false;
323 }
324}
325
326size_t PixelComponentSizeBitsInteger(PixelFormat format) {
327 switch (format) {
328 case PixelFormat::A8B8G8R8_SINT:
329 case PixelFormat::A8B8G8R8_UINT:
330 case PixelFormat::R8_SINT:
331 case PixelFormat::R8_UINT:
332 case PixelFormat::R8G8_SINT:
333 case PixelFormat::R8G8_UINT:
334 return 8;
335 case PixelFormat::A2B10G10R10_UINT:
336 return 10;
337 case PixelFormat::R16G16B16A16_SINT:
338 case PixelFormat::R16G16B16A16_UINT:
339 case PixelFormat::R16_UINT:
340 case PixelFormat::R16_SINT:
341 case PixelFormat::R16G16_UINT:
342 case PixelFormat::R16G16_SINT:
343 return 16;
344 case PixelFormat::R32G32B32A32_UINT:
345 case PixelFormat::R32G32B32A32_SINT:
346 case PixelFormat::R32G32_SINT:
347 case PixelFormat::R32G32_UINT:
348 case PixelFormat::R32_UINT:
349 case PixelFormat::R32_SINT:
350 return 32;
351 default:
352 return 0;
353 }
354}
355
309std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) { 356std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
310 return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; 357 return {DefaultBlockWidth(format), DefaultBlockHeight(format)};
311} 358}
diff --git a/src/video_core/surface.h b/src/video_core/surface.h
index 3bb24abb7..2ce7c7d33 100644
--- a/src/video_core/surface.h
+++ b/src/video_core/surface.h
@@ -462,6 +462,10 @@ bool IsPixelFormatSRGB(PixelFormat format);
462 462
463bool IsPixelFormatInteger(PixelFormat format); 463bool IsPixelFormatInteger(PixelFormat format);
464 464
465bool IsPixelFormatSignedInteger(PixelFormat format);
466
467size_t PixelComponentSizeBitsInteger(PixelFormat format);
468
465std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); 469std::pair<u32, u32> GetASTCBlockSize(PixelFormat format);
466 470
467u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format); 471u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format);