From 1b8985a0804268e6ed0ffca85bcad9cff828581b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 21 Mar 2016 00:35:27 -0700 Subject: [PATCH 1/3] thin3d: Fix tranposed Vulkan bufs. --- ext/native/thin3d/thin3d_vulkan.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index f1e3577800..b551b7bfa5 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -741,19 +741,13 @@ VkDescriptorSet Thin3DVKContext::GetOrCreateDescriptorSet(VkBuffer buf) { } VkDescriptorSet descSet; - VkDescriptorSetAllocateInfo alloc; - alloc.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; - alloc.pNext = nullptr; + VkDescriptorSetAllocateInfo alloc = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; alloc.descriptorPool = frame->descriptorPool; alloc.pSetLayouts = &descriptorSetLayout_; alloc.descriptorSetCount = 1; - // OutputDebugStringA("Allocated a desc set!\n"); VkResult res = vkAllocateDescriptorSets(device_, &alloc, &descSet); assert(VK_SUCCESS == res); - // bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; - // bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - VkDescriptorBufferInfo bufferDesc; bufferDesc.buffer = buf; bufferDesc.offset = 0; @@ -764,10 +758,8 @@ VkDescriptorSet Thin3DVKContext::GetOrCreateDescriptorSet(VkBuffer buf) { imageDesc.sampler = boundSamplers_[0]->GetSampler(); imageDesc.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - VkWriteDescriptorSet writes[2]; - memset(writes, 0, sizeof(writes)); + VkWriteDescriptorSet writes[2] = {}; writes[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - writes[0].pNext = nullptr; writes[0].dstSet = descSet; writes[0].dstArrayElement = 0; writes[0].dstBinding = 0; @@ -778,7 +770,6 @@ VkDescriptorSet Thin3DVKContext::GetOrCreateDescriptorSet(VkBuffer buf) { writes[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; writes[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - writes[1].pNext = nullptr; writes[1].dstSet = descSet; writes[1].dstArrayElement = 0; writes[1].dstBinding = 1; @@ -1098,8 +1089,8 @@ void Thin3DVKContext::Draw(T3DPrimitive prim, Thin3DShaderSet *shaderSet, Thin3D VkBuffer vulkanVbuf; VkBuffer vulkanUBObuf; - uint32_t ubo_offset = (uint32_t)curShaderSet_->PushUBO(push_, vulkan_, &vulkanVbuf); - size_t vbBindOffset = push_->Push(vbuf->GetData(), vbuf->GetSize(), &vulkanUBObuf); + uint32_t ubo_offset = (uint32_t)curShaderSet_->PushUBO(push_, vulkan_, &vulkanUBObuf); + size_t vbBindOffset = push_->Push(vbuf->GetData(), vbuf->GetSize(), &vulkanVbuf); VkPipeline pipeline = GetOrCreatePipeline(); vkCmdBindPipeline(cmd_, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); @@ -1118,8 +1109,8 @@ void Thin3DVKContext::DrawIndexed(T3DPrimitive prim, Thin3DShaderSet *shaderSet, curShaderSet_ = (Thin3DVKShaderSet *)shaderSet; curVertexFormat_ = (Thin3DVKVertexFormat *)format; - Thin3DVKBuffer *ibuf = (Thin3DVKBuffer *)idata; - Thin3DVKBuffer *vbuf = (Thin3DVKBuffer *)vdata; + Thin3DVKBuffer *ibuf = static_cast(idata); + Thin3DVKBuffer *vbuf = static_cast(vdata); VkBuffer vulkanVbuf, vulkanIbuf, vulkanUBObuf; uint32_t ubo_offset = (uint32_t)curShaderSet_->PushUBO(push_, vulkan_, &vulkanUBObuf); From f3d113a777e708f28fa4ebb2ce157da9d815032d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 21 Mar 2016 06:57:03 -0700 Subject: [PATCH 2/3] thin3d: Use 32-bit indexed drawing to match. --- ext/native/thin3d/thin3d_vulkan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index b551b7bfa5..f00bf86c7f 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -1127,7 +1127,7 @@ void Thin3DVKContext::DrawIndexed(T3DPrimitive prim, Thin3DShaderSet *shaderSet, VkDeviceSize offsets[1] = { vbBindOffset }; vkCmdBindVertexBuffers(cmd_, 0, 1, buffers, offsets); - vkCmdBindIndexBuffer(cmd_, vulkanIbuf, ibBindOffset, VK_INDEX_TYPE_UINT16); + vkCmdBindIndexBuffer(cmd_, vulkanIbuf, ibBindOffset, VK_INDEX_TYPE_UINT32); vkCmdDrawIndexed(cmd_, vertexCount, 1, 0, offset, 0); } From caea1da99aba3935e8bbcb27237f0345677bd190 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 21 Mar 2016 07:09:33 -0700 Subject: [PATCH 3/3] softgpu: Flip vertically in the Vulkan backend. --- GPU/Software/SoftGpu.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index d83fb02314..bad6c43826 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -191,6 +191,10 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) float v0 = 1.0f; float v1 = 0.0f; + if (GetGPUBackend() == GPUBackend::VULKAN) { + std::swap(v0, v1); + } + const Vertex verts[4] = { {x, y, 0, u0, v0, 0xFFFFFFFF}, // TL {x, y2, 0, u0, v1, 0xFFFFFFFF}, // BL