|
|
@@ -224,6 +224,61 @@ VK_IMPORT_DEVICE
|
|
|
};
|
|
|
BX_STATIC_ASSERT(TextureFormat::Count == BX_COUNTOF(s_textureFormat) );
|
|
|
|
|
|
+ struct Extension
|
|
|
+ {
|
|
|
+ enum Enum
|
|
|
+ {
|
|
|
+ EXT_debug_utils,
|
|
|
+ EXT_debug_report,
|
|
|
+
|
|
|
+ Count
|
|
|
+ };
|
|
|
+
|
|
|
+ const char* m_name;
|
|
|
+ uint32_t m_minVersion;
|
|
|
+ bool m_supported;
|
|
|
+ bool m_initialize;
|
|
|
+ };
|
|
|
+
|
|
|
+ // Extension registry
|
|
|
+ //
|
|
|
+ static Extension s_extension[] =
|
|
|
+ {
|
|
|
+ { "VK_EXT_debug_utils", 1, false, BGFX_CONFIG_DEBUG_OBJECT_NAME },
|
|
|
+ { "VK_EXT_debug_report", 1, false, BGFX_CONFIG_DEBUG },
|
|
|
+ };
|
|
|
+ BX_STATIC_ASSERT(Extension::Count == BX_COUNTOF(s_extension) );
|
|
|
+
|
|
|
+ void updateExtension(const char* _name, uint32_t _version)
|
|
|
+ {
|
|
|
+ bx::StringView ext(_name);
|
|
|
+
|
|
|
+ bool supported = false;
|
|
|
+ for (uint32_t ii = 0; ii < Extension::Count; ++ii)
|
|
|
+ {
|
|
|
+ Extension& extension = s_extension[ii];
|
|
|
+ if (!extension.m_supported
|
|
|
+ && extension.m_initialize)
|
|
|
+ {
|
|
|
+ if ( 0 == bx::strCmp(ext, extension.m_name)
|
|
|
+ && _version >= extension.m_minVersion)
|
|
|
+ {
|
|
|
+ extension.m_supported = true;
|
|
|
+ supported = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BX_TRACE("\tv%-3d %s%s"
|
|
|
+ , _version
|
|
|
+ , _name
|
|
|
+ , supported ? " (supported)" : "", _name
|
|
|
+ );
|
|
|
+
|
|
|
+ BX_UNUSED(supported);
|
|
|
+ }
|
|
|
+
|
|
|
static const VkFormat s_attribType[][4][2] =
|
|
|
{
|
|
|
{ // Uint8
|
|
|
@@ -357,6 +412,12 @@ VK_IMPORT_DEVICE
|
|
|
internalFreeNotification,
|
|
|
};
|
|
|
|
|
|
+ VkResult VKAPI_PTR stubSetDebugUtilsObjectNameEXT(VkDevice _device, const VkDebugUtilsObjectNameInfoEXT* _nameInfo)
|
|
|
+ {
|
|
|
+ BX_UNUSED(_device, _nameInfo);
|
|
|
+ return VK_SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
static const char* s_debugReportObjectType[] =
|
|
|
{
|
|
|
"Unknown",
|
|
|
@@ -455,21 +516,21 @@ VK_IMPORT_DEVICE
|
|
|
&& 0 < numExtensionProperties)
|
|
|
{
|
|
|
VkExtensionProperties extensionProperties[64];
|
|
|
- numExtensionProperties = bx::uint32_min(numExtensionProperties, BX_COUNTOF(extensionProperties) );
|
|
|
+ numExtensionProperties = bx::min<uint32_t>(numExtensionProperties, BX_COUNTOF(extensionProperties) );
|
|
|
result = enumerateExtensionProperties(_physicalDevice
|
|
|
, NULL
|
|
|
, &numExtensionProperties
|
|
|
, extensionProperties
|
|
|
);
|
|
|
|
|
|
- BX_TRACE("\tGlobal extensions (%d):"
|
|
|
+ BX_TRACE("Global extensions (%d):"
|
|
|
, numExtensionProperties
|
|
|
);
|
|
|
|
|
|
for (uint32_t extension = 0; extension < numExtensionProperties; ++extension)
|
|
|
{
|
|
|
- BX_TRACE("\t\t%s (s: 0x%08x)"
|
|
|
- , extensionProperties[extension].extensionName
|
|
|
+ updateExtension(
|
|
|
+ extensionProperties[extension].extensionName
|
|
|
, extensionProperties[extension].specVersion
|
|
|
);
|
|
|
}
|
|
|
@@ -484,10 +545,10 @@ VK_IMPORT_DEVICE
|
|
|
&& 0 < numLayerProperties)
|
|
|
{
|
|
|
VkLayerProperties layerProperties[64];
|
|
|
- numLayerProperties = bx::uint32_min(numLayerProperties, BX_COUNTOF(layerProperties) );
|
|
|
+ numLayerProperties = bx::min<uint32_t>(numLayerProperties, BX_COUNTOF(layerProperties) );
|
|
|
result = enumerateLayerProperties(_physicalDevice, &numLayerProperties, layerProperties);
|
|
|
|
|
|
- char indent = VK_NULL_HANDLE == _physicalDevice ? ' ' : '\t';
|
|
|
+ char indent = VK_NULL_HANDLE == _physicalDevice ? '\0' : '\t';
|
|
|
BX_UNUSED(indent);
|
|
|
|
|
|
BX_TRACE("%cLayer extensions (%d):"
|
|
|
@@ -514,7 +575,7 @@ VK_IMPORT_DEVICE
|
|
|
&& 0 < numExtensionProperties)
|
|
|
{
|
|
|
VkExtensionProperties extensionProperties[64];
|
|
|
- numExtensionProperties = bx::uint32_min(numExtensionProperties, BX_COUNTOF(extensionProperties) );
|
|
|
+ numExtensionProperties = bx::min<uint32_t>(numExtensionProperties, BX_COUNTOF(extensionProperties) );
|
|
|
result = enumerateExtensionProperties(_physicalDevice
|
|
|
, layerProperties[layer].layerName
|
|
|
, &numExtensionProperties
|
|
|
@@ -570,6 +631,35 @@ VK_IMPORT_DEVICE
|
|
|
return "<VkResult?>";
|
|
|
}
|
|
|
|
|
|
+ template<typename Ty>
|
|
|
+ VkObjectType getType();
|
|
|
+
|
|
|
+ template<> VkObjectType getType<VkBuffer >() { return VK_OBJECT_TYPE_BUFFER; }
|
|
|
+ template<> VkObjectType getType<VkShaderModule>() { return VK_OBJECT_TYPE_SHADER_MODULE; }
|
|
|
+
|
|
|
+ template<typename Ty>
|
|
|
+ static BX_NO_INLINE void setDebugObjectName(VkDevice _device, Ty _object, const char* _format, ...)
|
|
|
+ {
|
|
|
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_OBJECT_NAME) )
|
|
|
+ {
|
|
|
+ char temp[2048];
|
|
|
+ va_list argList;
|
|
|
+ va_start(argList, _format);
|
|
|
+ int32_t size = bx::min<int32_t>(sizeof(temp)-1, bx::vsnprintf(temp, sizeof(temp), _format, argList) );
|
|
|
+ va_end(argList);
|
|
|
+ temp[size] = '\0';
|
|
|
+
|
|
|
+ VkDebugUtilsObjectNameInfoEXT ni;
|
|
|
+ ni.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
|
|
|
+ ni.pNext = NULL;
|
|
|
+ ni.objectType = getType<Ty>();
|
|
|
+ ni.objectHandle = uint64_t(_object.vk);
|
|
|
+ ni.pObjectName = temp;
|
|
|
+
|
|
|
+ VK_CHECK(vkSetDebugUtilsObjectNameEXT(_device, &ni) );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void setImageMemoryBarrier(VkCommandBuffer _commandBuffer, VkImage _image, VkImageLayout _oldLayout, VkImageLayout _newLayout)
|
|
|
{
|
|
|
BX_CHECK(true
|
|
|
@@ -811,16 +901,27 @@ VK_IMPORT
|
|
|
/*not used*/ ""
|
|
|
};
|
|
|
|
|
|
- const char* enabledExtension[] =
|
|
|
+ uint32_t numEnabledExtensions = 2;
|
|
|
+
|
|
|
+ const char* enabledExtension[Extension::Count + numEnabledExtensions] =
|
|
|
{
|
|
|
VK_KHR_SURFACE_EXTENSION_NAME,
|
|
|
KHR_SURFACE_EXTENSION_NAME,
|
|
|
-#if BGFX_CONFIG_DEBUG
|
|
|
- VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
|
|
|
-#endif // BGFX_CONFIG_DEBUG
|
|
|
- /*not used*/ ""
|
|
|
};
|
|
|
|
|
|
+ for (uint32_t ii = 0; ii < Extension::Count; ++ii)
|
|
|
+ {
|
|
|
+ const Extension& extension = s_extension[ii];
|
|
|
+
|
|
|
+ if (extension.m_supported
|
|
|
+ && extension.m_initialize)
|
|
|
+ {
|
|
|
+ enabledExtension[numEnabledExtensions++] = extension.m_name;
|
|
|
+ BX_TRACE("%d: %s", numEnabledExtensions, extension.m_name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
VkInstanceCreateInfo ici;
|
|
|
ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
|
|
ici.pNext = NULL;
|
|
|
@@ -828,7 +929,7 @@ VK_IMPORT
|
|
|
ici.pApplicationInfo = &appInfo;
|
|
|
ici.enabledLayerCount = BX_COUNTOF(enabledLayerNames) - 1;
|
|
|
ici.ppEnabledLayerNames = enabledLayerNames;
|
|
|
- ici.enabledExtensionCount = BX_COUNTOF(enabledExtension) - 1;
|
|
|
+ ici.enabledExtensionCount = numEnabledExtensions;
|
|
|
ici.ppEnabledExtensionNames = enabledExtension;
|
|
|
|
|
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
|
|
@@ -868,7 +969,7 @@ VK_IMPORT_INSTANCE
|
|
|
|
|
|
m_debugReportCallback = VK_NULL_HANDLE;
|
|
|
|
|
|
- if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
|
|
|
+ if (s_extension[Extension::EXT_debug_report].m_supported)
|
|
|
{
|
|
|
VkDebugReportCallbackCreateInfoEXT drcb;
|
|
|
drcb.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
|
|
|
@@ -903,7 +1004,7 @@ VK_IMPORT_INSTANCE
|
|
|
}
|
|
|
|
|
|
VkPhysicalDevice physicalDevices[4];
|
|
|
- numPhysicalDevices = bx::uint32_min(numPhysicalDevices, BX_COUNTOF(physicalDevices) );
|
|
|
+ numPhysicalDevices = bx::min<uint32_t>(numPhysicalDevices, BX_COUNTOF(physicalDevices) );
|
|
|
result = vkEnumeratePhysicalDevices(m_instance
|
|
|
, &numPhysicalDevices
|
|
|
, physicalDevices
|
|
|
@@ -978,7 +1079,7 @@ VK_IMPORT_INSTANCE
|
|
|
g_caps.deviceId = uint16_t(m_deviceProperties.deviceID);
|
|
|
|
|
|
g_caps.limits.maxTextureSize = m_deviceProperties.limits.maxImageDimension2D;
|
|
|
- g_caps.limits.maxFBAttachments = uint8_t(bx::uint32_min(m_deviceProperties.limits.maxFragmentOutputAttachments, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS) );
|
|
|
+ g_caps.limits.maxFBAttachments = bx::min<uint8_t>(m_deviceProperties.limits.maxFragmentOutputAttachments, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS);
|
|
|
g_caps.limits.maxComputeBindings = BGFX_MAX_COMPUTE_BINDINGS;
|
|
|
|
|
|
{
|
|
|
@@ -1060,7 +1161,7 @@ VK_IMPORT_INSTANCE
|
|
|
);
|
|
|
|
|
|
VkQueueFamilyProperties queueFamilyPropertices[10] = {};
|
|
|
- queueFamilyPropertyCount = bx::uint32_min(queueFamilyPropertyCount, BX_COUNTOF(queueFamilyPropertices) );
|
|
|
+ queueFamilyPropertyCount = bx::min<uint32_t>(queueFamilyPropertyCount, BX_COUNTOF(queueFamilyPropertices) );
|
|
|
vkGetPhysicalDeviceQueueFamilyProperties(m_physicalDevice
|
|
|
, &queueFamilyPropertyCount
|
|
|
, queueFamilyPropertices
|
|
|
@@ -1359,7 +1460,7 @@ VK_IMPORT_DEVICE
|
|
|
}
|
|
|
|
|
|
VkSurfaceFormatKHR surfaceFormats[10];
|
|
|
- numSurfaceFormats = bx::uint32_min(numSurfaceFormats, BX_COUNTOF(surfaceFormats) );
|
|
|
+ numSurfaceFormats = bx::min<uint32_t>(numSurfaceFormats, BX_COUNTOF(surfaceFormats) );
|
|
|
vkGetPhysicalDeviceSurfaceFormatsKHR(m_physicalDevice, m_surface, &numSurfaceFormats, surfaceFormats);
|
|
|
|
|
|
// find the best match...
|
|
|
@@ -1374,7 +1475,7 @@ VK_IMPORT_DEVICE
|
|
|
}
|
|
|
|
|
|
VkPresentModeKHR presentModes[10];
|
|
|
- numPresentModes = bx::uint32_min(numPresentModes, BX_COUNTOF(presentModes) );
|
|
|
+ numPresentModes = bx::min<uint32_t>(numPresentModes, BX_COUNTOF(presentModes) );
|
|
|
vkGetPhysicalDeviceSurfacePresentModesKHR(m_physicalDevice, m_surface, &numPresentModes, presentModes);
|
|
|
|
|
|
// find the best match...
|
|
|
@@ -1706,9 +1807,10 @@ VK_IMPORT_DEVICE
|
|
|
|
|
|
VkDescriptorSetLayoutBinding dslb[] =
|
|
|
{
|
|
|
-// { DslBinding::CombinedImageSampler, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, VK_SHADER_STAGE_ALL, NULL },
|
|
|
- { DslBinding::UniformBuffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_ALL, NULL },
|
|
|
-// { DslBinding::StorageBuffer, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, VK_SHADER_STAGE_ALL, NULL },
|
|
|
+// { DslBinding::CombinedImageSampler, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, VK_SHADER_STAGE_ALL, NULL },
|
|
|
+ { DslBinding::VertexUniformBuffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_ALL, NULL },
|
|
|
+ { DslBinding::FragmentUniformBuffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, NULL },
|
|
|
+// { DslBinding::StorageBuffer, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, VK_SHADER_STAGE_ALL, NULL },
|
|
|
};
|
|
|
|
|
|
VkDescriptorPoolCreateInfo dpci;
|
|
|
@@ -1781,6 +1883,11 @@ VK_IMPORT_DEVICE
|
|
|
|
|
|
errorState = ErrorState::DescriptorCreated;
|
|
|
|
|
|
+ if (NULL == vkSetDebugUtilsObjectNameEXT)
|
|
|
+ {
|
|
|
+ vkSetDebugUtilsObjectNameEXT = stubSetDebugUtilsObjectNameEXT;
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
|
|
|
error:
|
|
|
@@ -2016,7 +2123,7 @@ VK_IMPORT_DEVICE
|
|
|
void updateDynamicIndexBuffer(IndexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
|
|
|
{
|
|
|
BX_UNUSED(_handle, _offset, _size, _mem);
|
|
|
-// m_indexBuffers[_handle.idx].update(m_commandBuffer, _offset, bx::uint32_min(_size, _mem->size), _mem->data);
|
|
|
+// m_indexBuffers[_handle.idx].update(m_commandBuffer, _offset, bx::min<uint32_t>(_size, _mem->size), _mem->data);
|
|
|
}
|
|
|
|
|
|
void destroyDynamicIndexBuffer(IndexBufferHandle _handle) override
|
|
|
@@ -2033,7 +2140,7 @@ VK_IMPORT_DEVICE
|
|
|
void updateDynamicVertexBuffer(VertexBufferHandle _handle, uint32_t _offset, uint32_t _size, const Memory* _mem) override
|
|
|
{
|
|
|
BX_UNUSED(_handle, _offset, _size, _mem);
|
|
|
-// m_vertexBuffers[_handle.idx].update(m_commandBuffer, _offset, bx::uint32_min(_size, _mem->size), _mem->data);
|
|
|
+// m_vertexBuffers[_handle.idx].update(m_commandBuffer, _offset, bx::min<uint32_t>(_size, _mem->size), _mem->data);
|
|
|
}
|
|
|
|
|
|
void destroyDynamicVertexBuffer(VertexBufferHandle _handle) override
|
|
|
@@ -2153,13 +2260,38 @@ VK_IMPORT_DEVICE
|
|
|
BX_UNUSED(_handle);
|
|
|
}
|
|
|
|
|
|
- void setMarker(const char* /*_marker*/, uint16_t /*_len*/) override
|
|
|
+ void setMarker(const char* _marker, uint16_t _len) override
|
|
|
{
|
|
|
+ if (BX_ENABLED(BGFX_CONFIG_DEBUG_PIX) )
|
|
|
+ {
|
|
|
+ BX_UNUSED(_marker, _len);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
virtual void setName(Handle _handle, const char* _name, uint16_t _len) override
|
|
|
{
|
|
|
- BX_UNUSED(_handle, _name, _len)
|
|
|
+ switch (_handle.type)
|
|
|
+ {
|
|
|
+ case Handle::IndexBuffer:
|
|
|
+ setDebugObjectName(m_device, m_indexBuffers[_handle.idx].m_buffer, "%.*s", _len, _name);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case Handle::Shader:
|
|
|
+ setDebugObjectName(m_device, m_shaders[_handle.idx].m_module, "%.*s", _len, _name);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case Handle::Texture:
|
|
|
+// setDebugObjectName(m_device, m_textures[_handle.idx].m_ptr, "%.*s", _len, _name);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case Handle::VertexBuffer:
|
|
|
+ setDebugObjectName(m_device, m_vertexBuffers[_handle.idx].m_buffer, "%.*s", _len, _name);
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void submitBlit(BlitState& _bs, uint16_t _view);
|
|
|
@@ -2281,20 +2413,22 @@ VK_IMPORT_DEVICE
|
|
|
void commitShaderUniforms(VkCommandBuffer _commandBuffer, ProgramHandle _program)
|
|
|
{
|
|
|
const ProgramVK& program = m_program[_program.idx];
|
|
|
- VkDescriptorBufferInfo descriptorBufferInfo;
|
|
|
- uint32_t total = 0
|
|
|
- + program.m_vsh->m_size
|
|
|
- + (NULL != program.m_fsh ? program.m_fsh->m_size : 0)
|
|
|
- ;
|
|
|
+
|
|
|
+ const uint32_t align = uint32_t(m_deviceProperties.limits.minUniformBufferOffsetAlignment);
|
|
|
+ const uint32_t vsize = bx::strideAlign(program.m_vsh->m_size, align);
|
|
|
+ const uint32_t fsize = bx::strideAlign( (NULL != program.m_fsh ? program.m_fsh->m_size : 0), align);
|
|
|
+ const uint32_t total = vsize + fsize;
|
|
|
+
|
|
|
if (0 < total)
|
|
|
{
|
|
|
- uint8_t* data = (uint8_t*)m_scratchBuffer[m_backBufferColorIdx].allocUbv(descriptorBufferInfo, total);
|
|
|
+ ScratchBufferVK& sb = m_scratchBuffer[m_backBufferColorIdx];
|
|
|
+
|
|
|
+ uint8_t* data = (uint8_t*)sb.allocUbv(vsize, fsize);
|
|
|
|
|
|
- uint32_t size = program.m_vsh->m_size;
|
|
|
- bx::memCopy(data, m_vsScratch, size);
|
|
|
- data += size;
|
|
|
+ bx::memCopy(data, m_vsScratch, program.m_vsh->m_size);
|
|
|
+ data += vsize;
|
|
|
|
|
|
- if (NULL != program.m_fsh)
|
|
|
+ if (0 != fsize)
|
|
|
{
|
|
|
bx::memCopy(data, m_fsScratch, program.m_fsh->m_size);
|
|
|
}
|
|
|
@@ -2304,8 +2438,7 @@ VK_IMPORT_DEVICE
|
|
|
, m_pipelineLayout
|
|
|
, 0
|
|
|
, 1
|
|
|
- , &m_scratchBuffer[m_backBufferColorIdx].m_descriptorSet
|
|
|
- [m_scratchBuffer[m_backBufferColorIdx].m_currentDs - 1]
|
|
|
+ , &sb.m_descriptorSet[sb.m_currentDs - 1]
|
|
|
, 0
|
|
|
, NULL
|
|
|
);
|
|
|
@@ -2903,7 +3036,7 @@ VK_IMPORT_DEVICE
|
|
|
// if (isValid(fbh) )
|
|
|
// {
|
|
|
// const FrameBufferVK& fb = m_frameBuffers[fbh.idx];
|
|
|
-// numMrt = bx::uint32_max(1, fb.m_num);
|
|
|
+// numMrt = bx::max(1, fb.m_num);
|
|
|
// }
|
|
|
|
|
|
VkClearAttachment attachments[BGFX_CONFIG_MAX_FRAME_BUFFERS];
|
|
|
@@ -2918,7 +3051,7 @@ VK_IMPORT_DEVICE
|
|
|
{
|
|
|
attachments[mrt].colorAttachment = mrt;
|
|
|
attachments[mrt].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
|
- uint8_t index = (uint8_t)bx::uint32_min(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
|
|
|
+ uint8_t index = bx::min<uint8_t>(BGFX_CONFIG_MAX_COLOR_PALETTE-1, _clear.m_index[ii]);
|
|
|
bx::memCopy(&attachments[mrt].clearValue.color.float32, _palette[index], 16);
|
|
|
++mrt;
|
|
|
}
|
|
|
@@ -3205,30 +3338,54 @@ VK_DESTROY
|
|
|
m_currentDs = 0;
|
|
|
}
|
|
|
|
|
|
- void* ScratchBufferVK::allocUbv(VkDescriptorBufferInfo& _descriptorBufferInfo, uint32_t _size)
|
|
|
+ void* ScratchBufferVK::allocUbv(uint32_t _vsize, uint32_t _fsize)
|
|
|
{
|
|
|
- uint32_t total = bx::strideAlign(_size
|
|
|
- , uint32_t(s_renderVK->m_deviceProperties.limits.minUniformBufferOffsetAlignment)
|
|
|
- );
|
|
|
- _descriptorBufferInfo.buffer = m_buffer;
|
|
|
- _descriptorBufferInfo.offset = m_pos;
|
|
|
- _descriptorBufferInfo.range = total;
|
|
|
+ VkDescriptorBufferInfo dbi[2];
|
|
|
+
|
|
|
+ dbi[0].buffer = m_buffer;
|
|
|
+ dbi[0].offset = m_pos;
|
|
|
+ dbi[0].range = _vsize;
|
|
|
+
|
|
|
+ VkWriteDescriptorSet wds[2];
|
|
|
|
|
|
- VkWriteDescriptorSet wds[1];
|
|
|
wds[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
|
wds[0].pNext = NULL;
|
|
|
wds[0].dstSet = m_descriptorSet[m_currentDs];
|
|
|
- wds[0].dstBinding = DslBinding::UniformBuffer;
|
|
|
+ wds[0].dstBinding = DslBinding::VertexUniformBuffer;
|
|
|
wds[0].dstArrayElement = 0;
|
|
|
wds[0].descriptorCount = 1;
|
|
|
wds[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
|
|
wds[0].pImageInfo = NULL;
|
|
|
- wds[0].pBufferInfo = &_descriptorBufferInfo;
|
|
|
+ wds[0].pBufferInfo = &dbi[0];
|
|
|
wds[0].pTexelBufferView = NULL;
|
|
|
- vkUpdateDescriptorSets(s_renderVK->m_device, BX_COUNTOF(wds), wds, 0, NULL);
|
|
|
+
|
|
|
+ uint32_t numWds = 1;
|
|
|
+
|
|
|
+ if (0 != _fsize)
|
|
|
+ {
|
|
|
+ dbi[1].buffer = m_buffer;
|
|
|
+ dbi[1].offset = m_pos + _vsize;
|
|
|
+ dbi[1].range = _fsize;
|
|
|
+
|
|
|
+ wds[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
|
+ wds[1].pNext = NULL;
|
|
|
+ wds[1].dstSet = m_descriptorSet[m_currentDs];
|
|
|
+ wds[1].dstBinding = DslBinding::FragmentUniformBuffer;
|
|
|
+ wds[1].dstArrayElement = 0;
|
|
|
+ wds[1].descriptorCount = 1;
|
|
|
+ wds[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
|
|
+ wds[1].pImageInfo = NULL;
|
|
|
+ wds[1].pBufferInfo = &dbi[1];
|
|
|
+ wds[1].pTexelBufferView = NULL;
|
|
|
+
|
|
|
+ ++numWds;
|
|
|
+ }
|
|
|
+
|
|
|
+ vkUpdateDescriptorSets(s_renderVK->m_device, numWds, wds, 0, NULL);
|
|
|
|
|
|
void* data = &m_data[m_pos];
|
|
|
- m_pos += total;
|
|
|
+
|
|
|
+ m_pos += _vsize + _fsize;
|
|
|
++m_currentDs;
|
|
|
|
|
|
return data;
|
|
|
@@ -3570,6 +3727,9 @@ VK_DESTROY
|
|
|
smci.flags = 0;
|
|
|
smci.codeSize = m_code->size;
|
|
|
smci.pCode = (const uint32_t*)m_code->data;
|
|
|
+
|
|
|
+// disassemble(bx::getDebugOut(), m_code->data, m_code->size);
|
|
|
+
|
|
|
VK_CHECK(vkCreateShaderModule(
|
|
|
s_renderVK->m_device
|
|
|
, &smci
|