Vulkan CP: Fix calculating an invalid copy destination base address when sizeof(texel) != 4
This commit is contained in:
parent
7c5042add7
commit
79f1193130
|
@ -88,6 +88,66 @@ enum class TextureFormat : uint32_t {
|
||||||
kUnknown = 0xFFFFFFFFu,
|
kUnknown = 0xFFFFFFFFu,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline size_t GetTexelSize(TextureFormat format) {
|
||||||
|
switch (format) {
|
||||||
|
case TextureFormat::k_1_5_5_5:
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_2_10_10_10:
|
||||||
|
return 4;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_4_4_4_4:
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_5_6_5:
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_8:
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_8_8:
|
||||||
|
return 2;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_8_8_8_8:
|
||||||
|
return 4;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_16:
|
||||||
|
return 4;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_16_FLOAT:
|
||||||
|
return 4;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_16_16:
|
||||||
|
return 4;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_16_16_FLOAT:
|
||||||
|
return 4;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_16_16_16_16:
|
||||||
|
return 8;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_16_16_16_16_FLOAT:
|
||||||
|
return 8;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_32_FLOAT:
|
||||||
|
return 4;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_32_32_FLOAT:
|
||||||
|
return 8;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_32_32_32_32_FLOAT:
|
||||||
|
return 16;
|
||||||
|
break;
|
||||||
|
case TextureFormat::k_10_11_11:
|
||||||
|
case TextureFormat::k_11_11_10:
|
||||||
|
return 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert_unhandled_case(format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline TextureFormat ColorFormatToTextureFormat(ColorFormat color_format) {
|
inline TextureFormat ColorFormatToTextureFormat(ColorFormat color_format) {
|
||||||
return static_cast<TextureFormat>(color_format);
|
return static_cast<TextureFormat>(color_format);
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,7 +362,7 @@ void VulkanCommandProcessor::PerformSwap(uint32_t frontbuffer_ptr,
|
||||||
command_buffer_pool_->EndBatch(current_batch_fence_);
|
command_buffer_pool_->EndBatch(current_batch_fence_);
|
||||||
|
|
||||||
// TODO(DrChat): Remove this.
|
// TODO(DrChat): Remove this.
|
||||||
VkFence fences[] = { *current_batch_fence_ };
|
VkFence fences[] = {*current_batch_fence_};
|
||||||
vkWaitForFences(*device_, 1, fences, true, -1);
|
vkWaitForFences(*device_, 1, fences, true, -1);
|
||||||
|
|
||||||
// Scavenging.
|
// Scavenging.
|
||||||
|
@ -733,9 +733,10 @@ bool VulkanCommandProcessor::PopulateVertexBuffers(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VulkanCommandProcessor::PopulateSamplers(
|
bool VulkanCommandProcessor::PopulateSamplers(VkCommandBuffer command_buffer,
|
||||||
VkCommandBuffer command_buffer, VkCommandBuffer setup_buffer,
|
VkCommandBuffer setup_buffer,
|
||||||
VulkanShader* vertex_shader, VulkanShader* pixel_shader) {
|
VulkanShader* vertex_shader,
|
||||||
|
VulkanShader* pixel_shader) {
|
||||||
#if FINE_GRAINED_DRAW_SCOPES
|
#if FINE_GRAINED_DRAW_SCOPES
|
||||||
SCOPE_profile_cpu_f("gpu");
|
SCOPE_profile_cpu_f("gpu");
|
||||||
#endif // FINE_GRAINED_DRAW_SCOPES
|
#endif // FINE_GRAINED_DRAW_SCOPES
|
||||||
|
@ -829,11 +830,13 @@ bool VulkanCommandProcessor::IssueCopy() {
|
||||||
window_offset_y |= 0x8000;
|
window_offset_y |= 0x8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t read_size = GetTexelSize(ColorFormatToTextureFormat(copy_dest_format));
|
||||||
|
|
||||||
// Adjust the copy base offset to point to the beginning of the texture, so
|
// Adjust the copy base offset to point to the beginning of the texture, so
|
||||||
// we don't run into hiccups down the road (e.g. resolving the last part going
|
// we don't run into hiccups down the road (e.g. resolving the last part going
|
||||||
// backwards).
|
// backwards).
|
||||||
int32_t dest_offset = window_offset_y * copy_dest_pitch * 4;
|
int32_t dest_offset = window_offset_y * copy_dest_pitch * int(read_size);
|
||||||
dest_offset += window_offset_x * 32 * 4;
|
dest_offset += window_offset_x * 32 * int(read_size);
|
||||||
copy_dest_base += dest_offset;
|
copy_dest_base += dest_offset;
|
||||||
|
|
||||||
// HACK: vertices to use are always in vf0.
|
// HACK: vertices to use are always in vf0.
|
||||||
|
|
Loading…
Reference in New Issue