Merge branch 'master' of https://github.com/SaschaWillems/Vulkan
This commit is contained in:
commit
d28d9279f5
5 changed files with 7 additions and 11 deletions
|
|
@ -4,7 +4,7 @@ apply from: '../gradle/outputfilename.gradle'
|
|||
android {
|
||||
compileSdkVersion 26
|
||||
defaultConfig {
|
||||
applicationId "de.saschawillems.vulkanDeferredmulitsampling"
|
||||
applicationId "de.saschawillems.vulkanDeferredmultisampling"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 26
|
||||
versionCode 1
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.saschawillems.vulkanDeferredmulitsampling">
|
||||
package="de.saschawillems.vulkanDeferredmultisampling">
|
||||
|
||||
<application
|
||||
android:label="Vulkan deferred multi sampling"
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ struct GeometryInstance {
|
|||
#define INDEX_MISS 1
|
||||
#define INDEX_CLOSEST_HIT 2
|
||||
|
||||
#define NUM_SHADER_GROUPS 3
|
||||
|
||||
class VulkanExample : public VulkanExampleBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -414,7 +416,6 @@ public:
|
|||
VkDeviceSize copyShaderIdentifier(uint8_t* data, const uint8_t* shaderHandleStorage, uint32_t groupIndex) {
|
||||
const uint32_t shaderGroupHandleSize = rayTracingProperties.shaderGroupHandleSize;
|
||||
memcpy(data, shaderHandleStorage + groupIndex * shaderGroupHandleSize, shaderGroupHandleSize);
|
||||
data += shaderGroupHandleSize;
|
||||
return shaderGroupHandleSize;
|
||||
}
|
||||
|
||||
|
|
@ -423,7 +424,7 @@ public:
|
|||
*/
|
||||
void createShaderBindingTable() {
|
||||
// Create buffer for the shader binding table
|
||||
const uint32_t sbtSize = rayTracingProperties.shaderGroupHandleSize * 3;
|
||||
const uint32_t sbtSize = rayTracingProperties.shaderGroupHandleSize * NUM_SHADER_GROUPS;
|
||||
VK_CHECK_RESULT(vulkanDevice->createBuffer(
|
||||
VK_BUFFER_USAGE_RAY_TRACING_BIT_NV,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
||||
|
|
@ -433,10 +434,9 @@ public:
|
|||
|
||||
auto shaderHandleStorage = new uint8_t[sbtSize];
|
||||
// Get shader identifiers
|
||||
VK_CHECK_RESULT(vkGetRayTracingShaderGroupHandlesNV(device, pipeline, 0, 3, sbtSize, shaderHandleStorage));
|
||||
VK_CHECK_RESULT(vkGetRayTracingShaderGroupHandlesNV(device, pipeline, 0, NUM_SHADER_GROUPS, sbtSize, shaderHandleStorage));
|
||||
auto* data = static_cast<uint8_t*>(shaderBindingTable.mapped);
|
||||
// Copy the shader identifiers to the shader binding table
|
||||
VkDeviceSize offset = 0;
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_RAYGEN);
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_MISS);
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_CLOSEST_HIT);
|
||||
|
|
@ -542,7 +542,7 @@ public:
|
|||
/*
|
||||
Setup ray tracing shader groups
|
||||
*/
|
||||
std::array<VkRayTracingShaderGroupCreateInfoNV, 3> groups{};
|
||||
std::array<VkRayTracingShaderGroupCreateInfoNV, NUM_SHADER_GROUPS> groups{};
|
||||
for (auto& group : groups) {
|
||||
// Init all groups with some default values
|
||||
group.sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV;
|
||||
|
|
|
|||
|
|
@ -403,7 +403,6 @@ public:
|
|||
VkDeviceSize copyShaderIdentifier(uint8_t* data, const uint8_t* shaderHandleStorage, uint32_t groupIndex) {
|
||||
const uint32_t shaderGroupHandleSize = rayTracingProperties.shaderGroupHandleSize;
|
||||
memcpy(data, shaderHandleStorage + groupIndex * shaderGroupHandleSize, shaderGroupHandleSize);
|
||||
data += shaderGroupHandleSize;
|
||||
return shaderGroupHandleSize;
|
||||
}
|
||||
|
||||
|
|
@ -425,7 +424,6 @@ public:
|
|||
VK_CHECK_RESULT(vkGetRayTracingShaderGroupHandlesNV(device, pipeline, 0, NUM_SHADER_GROUPS, sbtSize, shaderHandleStorage));
|
||||
auto* data = static_cast<uint8_t*>(shaderBindingTable.mapped);
|
||||
// Copy the shader identifiers to the shader binding table
|
||||
VkDeviceSize offset = 0;
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_RAYGEN);
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_MISS);
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_CLOSEST_HIT);
|
||||
|
|
|
|||
|
|
@ -412,7 +412,6 @@ public:
|
|||
VkDeviceSize copyShaderIdentifier(uint8_t* data, const uint8_t* shaderHandleStorage, uint32_t groupIndex) {
|
||||
const uint32_t shaderGroupHandleSize = rayTracingProperties.shaderGroupHandleSize;
|
||||
memcpy(data, shaderHandleStorage + groupIndex * shaderGroupHandleSize, shaderGroupHandleSize);
|
||||
data += shaderGroupHandleSize;
|
||||
return shaderGroupHandleSize;
|
||||
}
|
||||
|
||||
|
|
@ -434,7 +433,6 @@ public:
|
|||
VK_CHECK_RESULT(vkGetRayTracingShaderGroupHandlesNV(device, pipeline, 0, NUM_SHADER_GROUPS, sbtSize, shaderHandleStorage));
|
||||
auto* data = static_cast<uint8_t*>(shaderBindingTable.mapped);
|
||||
// Copy the shader identifiers to the shader binding table
|
||||
VkDeviceSize offset = 0;
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_RAYGEN);
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_MISS);
|
||||
data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_SHADOW_MISS);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue