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

View File

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