remove bufferdeviceaddress

This commit is contained in:
Zack Buhman 2026-04-08 14:15:14 -05:00
parent 256969454f
commit 024a42e691
2 changed files with 17 additions and 10 deletions

View File

@ -27,7 +27,8 @@ struct PushConstant {
}; };
[[vk::push_constant]] [[vk::push_constant]]
struct PushConstant constants; ShaderData data;
//struct PushConstant constants;
[[vk::binding(0)]] SamplerState samplers[]; [[vk::binding(0)]] SamplerState samplers[];
[[vk::binding(0)]] Texture2D textures[]; [[vk::binding(0)]] Texture2D textures[];
@ -36,12 +37,12 @@ struct PushConstant constants;
VSOutput VSMain(VSInput input) VSOutput VSMain(VSInput input)
{ {
VSOutput output = (VSOutput)0; VSOutput output = (VSOutput)0;
output.Position = mul(constants.data.Get().Transform, float4(input.Position.xyz, 1.0)); output.Position = mul(data.Transform, float4(input.Position.xyz, 1.0));
output.Normal = mul((float3x3)constants.data.Get().ModelView, input.Normal); output.Normal = mul((float3x3)data.ModelView, input.Normal);
output.Texture = input.Texture.xy; output.Texture = input.Texture.xy;
float4 viewPosition = mul(constants.data.Get().ModelView, float4(input.Position.xyz, 1.0)); float4 viewPosition = mul(data.ModelView, float4(input.Position.xyz, 1.0));
output.LightDirection = (constants.data.Get().LightPosition - viewPosition).xyz; output.LightDirection = (data.LightPosition - viewPosition).xyz;
output.ViewDirection = -viewPosition.xyz; output.ViewDirection = -viewPosition.xyz;
return output; return output;
@ -75,7 +76,7 @@ VSOutlineOutput VSOutlineMain(VSInput input)
{ {
VSOutlineOutput output = (VSOutlineOutput)0; VSOutlineOutput output = (VSOutlineOutput)0;
float3 position = input.Position.xyz + input.Normal.xyz * 0.01; float3 position = input.Position.xyz + input.Normal.xyz * 0.01;
output.Position = mul(constants.data.Get().Transform, float4(position, 1.0)); output.Position = mul(data.Transform, float4(position, 1.0));
return output; return output;
} }

View File

@ -509,7 +509,7 @@ int main()
.shaderSampledImageArrayNonUniformIndexing = true, .shaderSampledImageArrayNonUniformIndexing = true,
.descriptorBindingVariableDescriptorCount = true, .descriptorBindingVariableDescriptorCount = true,
.runtimeDescriptorArray = true, .runtimeDescriptorArray = true,
.bufferDeviceAddress = true //.bufferDeviceAddress = true
}; };
VkPhysicalDeviceVulkan13Features enabledVulkan13Features{ VkPhysicalDeviceVulkan13Features enabledVulkan13Features{
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
@ -649,7 +649,7 @@ int main()
vkGetBufferMemoryRequirements(device, shaderDataDevice.frame[0].buffer, &memoryRequirements); vkGetBufferMemoryRequirements(device, shaderDataDevice.frame[0].buffer, &memoryRequirements);
VkMemoryPropertyFlags memoryPropertyFlags{ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT }; VkMemoryPropertyFlags memoryPropertyFlags{ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT };
VkMemoryAllocateFlags memoryAllocateFlags{ VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT }; VkMemoryAllocateFlags memoryAllocateFlags{ /*VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT*/ };
shaderDataDevice.stride = allocateFromMemoryRequirements(physicalDeviceMemoryProperties, shaderDataDevice.stride = allocateFromMemoryRequirements(physicalDeviceMemoryProperties,
memoryRequirements, memoryRequirements,
memoryPropertyFlags, memoryPropertyFlags,
@ -667,11 +667,13 @@ int main()
VK_CHECK(vkBindBufferMemory(device, shaderDataDevice.frame[i].buffer, shaderDataDevice.memory, offset)); VK_CHECK(vkBindBufferMemory(device, shaderDataDevice.frame[i].buffer, shaderDataDevice.memory, offset));
/*
VkBufferDeviceAddressInfo bufferDeviceAddressInfo{ VkBufferDeviceAddressInfo bufferDeviceAddressInfo{
.sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO, .sType = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO,
.buffer = shaderDataDevice.frame[i].buffer .buffer = shaderDataDevice.frame[i].buffer
}; };
shaderDataDevice.frame[i].deviceAddress = vkGetBufferDeviceAddress(device, &bufferDeviceAddressInfo); shaderDataDevice.frame[i].deviceAddress = vkGetBufferDeviceAddress(device, &bufferDeviceAddressInfo);
*/
} }
} }
@ -979,7 +981,8 @@ int main()
VkPushConstantRange pushConstantRange{ VkPushConstantRange pushConstantRange{
.stageFlags = VK_SHADER_STAGE_VERTEX_BIT, .stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
.size = (sizeof (VkDeviceAddress)) //.size = (sizeof (VkDeviceAddress))
.size = (sizeof (ShaderData))
}; };
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo{ VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo{
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
@ -1201,6 +1204,7 @@ int main()
size_t frameOffset = shaderDataDevice.stride * frameIndex; size_t frameOffset = shaderDataDevice.stride * frameIndex;
void * frameData = (void *)(((VkDeviceSize)shaderDataDevice.mappedData) + frameOffset); void * frameData = (void *)(((VkDeviceSize)shaderDataDevice.mappedData) + frameOffset);
VkDeviceSize frameSize{ (sizeof (ShaderData)) }; VkDeviceSize frameSize{ (sizeof (ShaderData)) };
/*
memcpy(frameData, &shaderData, frameSize); memcpy(frameData, &shaderData, frameSize);
VkDeviceSize flushSize{ roundAlignment(frameSize, physicalDeviceProperties.limits.nonCoherentAtomSize) }; VkDeviceSize flushSize{ roundAlignment(frameSize, physicalDeviceProperties.limits.nonCoherentAtomSize) };
VkMappedMemoryRange shaderDataMemoryRange{ VkMappedMemoryRange shaderDataMemoryRange{
@ -1210,6 +1214,7 @@ int main()
.size = flushSize, .size = flushSize,
}; };
vkFlushMappedMemoryRanges(device, 1, &shaderDataMemoryRange); vkFlushMappedMemoryRanges(device, 1, &shaderDataMemoryRange);
*/
// command buffer // command buffer
VkCommandBuffer& commandBuffer = commandBuffers[frameIndex]; VkCommandBuffer& commandBuffer = commandBuffers[frameIndex];
@ -1302,7 +1307,8 @@ int main()
vkCmdBindVertexBuffers(commandBuffer, 0, 1, &vertexIndexBuffer, &vertexOffset); vkCmdBindVertexBuffers(commandBuffer, 0, 1, &vertexIndexBuffer, &vertexOffset);
VkDeviceSize indexOffset{ vertexBufferSize }; VkDeviceSize indexOffset{ vertexBufferSize };
vkCmdBindIndexBuffer(commandBuffer, vertexIndexBuffer, indexOffset, VK_INDEX_TYPE_UINT32); vkCmdBindIndexBuffer(commandBuffer, vertexIndexBuffer, indexOffset, VK_INDEX_TYPE_UINT32);
vkCmdPushConstants(commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, (sizeof (VkDeviceAddress)), &shaderDataDevice.frame[frameIndex].deviceAddress); //vkCmdPushConstants(commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, (sizeof (VkDeviceAddress)), &shaderDataDevice.frame[frameIndex].deviceAddress);
vkCmdPushConstants(commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, (sizeof (ShaderData)), &shaderData);
VkDeviceSize indexCount{ 9216 }; VkDeviceSize indexCount{ 9216 };
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[MAIN_PIPELINE]); vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines[MAIN_PIPELINE]);