Vulkan cleanup and minor bug fixes (#2129)

This commit is contained in:
Hugo Amnov 2020-05-03 22:27:31 +02:00 committed by GitHub
parent 9e0327401a
commit f9b1a9f5d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 30 deletions

View File

@ -7,5 +7,8 @@
void main() void main()
{ {
// Vulkan does not like shader writing to a target that is not attached
#ifndef BGFX_SHADER_LANGUAGE_SPIRV
gl_FragColor = vec4_splat(0.0); gl_FragColor = vec4_splat(0.0);
#endif
} }

View File

@ -2804,9 +2804,6 @@ VK_IMPORT_DEVICE
wds[2].pBufferInfo = NULL; wds[2].pBufferInfo = NULL;
wds[2].pTexelBufferView = NULL; wds[2].pTexelBufferView = NULL;
m_vsChanges = 0;
m_fsChanges = 0;
vkUpdateDescriptorSets(m_device, 3, wds, 0, NULL); vkUpdateDescriptorSets(m_device, 3, wds, 0, NULL);
vkCmdBindDescriptorSets( vkCmdBindDescriptorSets(
m_commandBuffer m_commandBuffer
@ -3013,16 +3010,13 @@ VK_IMPORT_DEVICE
void setShaderUniform(uint8_t _flags, uint32_t _regIndex, const void* _val, uint32_t _numRegs) void setShaderUniform(uint8_t _flags, uint32_t _regIndex, const void* _val, uint32_t _numRegs)
{ {
BX_UNUSED(_flags, _regIndex, _val, _numRegs);
if (_flags & BGFX_UNIFORM_FRAGMENTBIT) if (_flags & BGFX_UNIFORM_FRAGMENTBIT)
{ {
bx::memCopy(&m_fsScratch[_regIndex], _val, _numRegs*16); bx::memCopy(&m_fsScratch[_regIndex], _val, _numRegs*16);
m_fsChanges += _numRegs;
} }
else else
{ {
bx::memCopy(&m_vsScratch[_regIndex], _val, _numRegs*16); bx::memCopy(&m_vsScratch[_regIndex], _val, _numRegs*16);
m_vsChanges += _numRegs;
} }
} }
@ -3070,9 +3064,6 @@ VK_IMPORT_DEVICE
// , NULL // , NULL
// ); // );
// } // }
//
// m_vsChanges = 0;
// m_fsChanges = 0;
// } // }
void setFrameBuffer(FrameBufferHandle _fbh, bool _msaa = true) void setFrameBuffer(FrameBufferHandle _fbh, bool _msaa = true)
@ -3604,7 +3595,10 @@ VK_IMPORT_DEVICE
murmur.add(_stencil); murmur.add(_stencil);
murmur.add(program.m_vsh->m_hash); murmur.add(program.m_vsh->m_hash);
murmur.add(program.m_vsh->m_attrMask, sizeof(program.m_vsh->m_attrMask) ); murmur.add(program.m_vsh->m_attrMask, sizeof(program.m_vsh->m_attrMask) );
if (NULL != program.m_fsh)
{
murmur.add(program.m_fsh->m_hash); murmur.add(program.m_fsh->m_hash);
}
for (uint8_t ii = 0; ii < _numStreams; ++ii) for (uint8_t ii = 0; ii < _numStreams; ++ii)
{ {
murmur.add(_layouts[ii]->m_hash); murmur.add(_layouts[ii]->m_hash);
@ -3670,6 +3664,9 @@ VK_IMPORT_DEVICE
shaderStages[0].module = program.m_vsh->m_module; shaderStages[0].module = program.m_vsh->m_module;
shaderStages[0].pName = "main"; shaderStages[0].pName = "main";
shaderStages[0].pSpecializationInfo = NULL; shaderStages[0].pSpecializationInfo = NULL;
if (NULL != program.m_fsh)
{
shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
shaderStages[1].pNext = NULL; shaderStages[1].pNext = NULL;
shaderStages[1].flags = 0; shaderStages[1].flags = 0;
@ -3677,6 +3674,7 @@ VK_IMPORT_DEVICE
shaderStages[1].module = program.m_fsh->m_module; shaderStages[1].module = program.m_fsh->m_module;
shaderStages[1].pName = "main"; shaderStages[1].pName = "main";
shaderStages[1].pSpecializationInfo = NULL; shaderStages[1].pSpecializationInfo = NULL;
}
VkPipelineViewportStateCreateInfo viewportState; VkPipelineViewportStateCreateInfo viewportState;
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
@ -3702,7 +3700,7 @@ VK_IMPORT_DEVICE
graphicsPipeline.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; graphicsPipeline.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
graphicsPipeline.pNext = NULL; graphicsPipeline.pNext = NULL;
graphicsPipeline.flags = 0; graphicsPipeline.flags = 0;
graphicsPipeline.stageCount = BX_COUNTOF(shaderStages); graphicsPipeline.stageCount = NULL == program.m_fsh ? 1 : 2;
graphicsPipeline.pStages = shaderStages; graphicsPipeline.pStages = shaderStages;
graphicsPipeline.pVertexInputState = &vertexInputState; graphicsPipeline.pVertexInputState = &vertexInputState;
graphicsPipeline.pInputAssemblyState = &inputAssemblyState; graphicsPipeline.pInputAssemblyState = &inputAssemblyState;
@ -3935,7 +3933,7 @@ VK_IMPORT_DEVICE
if (0 < total) if (0 < total)
{ {
uint32_t vsUniformBinding = program.m_vsh->m_uniformBinding; uint32_t vsUniformBinding = program.m_vsh->m_uniformBinding;
uint32_t fsUniformBinding = program.m_fsh ? program.m_fsh->m_uniformBinding : 0; uint32_t fsUniformBinding = NULL != program.m_fsh ? program.m_fsh->m_uniformBinding : 0;
if (vsize > 0) if (vsize > 0)
{ {
@ -4080,7 +4078,7 @@ VK_IMPORT_DEVICE
if (isValid(fbh) ) if (isValid(fbh) )
{ {
const FrameBufferVK& fb = m_frameBuffers[fbh.idx]; const FrameBufferVK& fb = m_frameBuffers[fbh.idx];
numMrt = bx::max((uint8_t)1, fb.m_num); numMrt = fb.m_num;
} }
VkClearAttachment attachments[BGFX_CONFIG_MAX_FRAME_BUFFERS]; VkClearAttachment attachments[BGFX_CONFIG_MAX_FRAME_BUFFERS];
@ -4305,8 +4303,6 @@ VK_IMPORT_DEVICE
VkFence m_fence; VkFence m_fence;
VkRenderPass m_renderPass; VkRenderPass m_renderPass;
VkDescriptorPool m_descriptorPool; VkDescriptorPool m_descriptorPool;
// VkDescriptorSetLayout m_descriptorSetLayout;
// VkPipelineLayout m_pipelineLayout;
VkPipelineCache m_pipelineCache; VkPipelineCache m_pipelineCache;
VkCommandPool m_commandPool; VkCommandPool m_commandPool;
@ -4338,8 +4334,6 @@ VK_IMPORT_DEVICE
uint8_t m_fsScratch[64<<10]; uint8_t m_fsScratch[64<<10];
uint8_t m_vsScratch[64<<10]; uint8_t m_vsScratch[64<<10];
uint32_t m_fsChanges;
uint32_t m_vsChanges;
uint32_t m_backBufferColorIdx; uint32_t m_backBufferColorIdx;
FrameBufferHandle m_fbh; FrameBufferHandle m_fbh;
@ -6113,9 +6107,6 @@ VK_DESTROY
offset = scratchBuffer.m_pos; offset = scratchBuffer.m_pos;
m_vsChanges = 0;
m_fsChanges = 0;
bx::memCopy(&scratchBuffer.m_data[scratchBuffer.m_pos], m_vsScratch, program.m_vsh->m_size); bx::memCopy(&scratchBuffer.m_data[scratchBuffer.m_pos], m_vsScratch, program.m_vsh->m_size);
scratchBuffer.m_pos += vsize; scratchBuffer.m_pos += vsize;
@ -6425,8 +6416,6 @@ VK_DESTROY
bx::memCopy(&scratchBuffer.m_data[scratchBuffer.m_pos + vsize], m_fsScratch, program.m_fsh->m_size); bx::memCopy(&scratchBuffer.m_data[scratchBuffer.m_pos + vsize], m_fsScratch, program.m_fsh->m_size);
} }
m_vsChanges = 0;
m_fsChanges = 0;
scratchBuffer.m_pos += total; scratchBuffer.m_pos += total;
} }