mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-25 15:16:22 +00:00
Test constant buffer offsetting in cbuffer zoo tests
This commit is contained in:
@@ -300,10 +300,16 @@ float4 main() : SV_Target0
|
||||
ID3DBlobPtr vsblob = Compile(D3DDefaultVertex, "main", "vs_5_0");
|
||||
ID3DBlobPtr psblob = Compile(pixel, "main", "ps_5_1");
|
||||
|
||||
Vec4f cbufferdata[512];
|
||||
const size_t bindOffset = 16;
|
||||
|
||||
Vec4f cbufferdata[bindOffset + 512];
|
||||
|
||||
for(int i = 0; i < bindOffset; i++)
|
||||
cbufferdata[i] = Vec4f(-99.9f, -88.8f, -77.7f, -66.6f);
|
||||
|
||||
for(int i = 0; i < 512; i++)
|
||||
cbufferdata[i] = Vec4f(float(i * 4 + 0), float(i * 4 + 1), float(i * 4 + 2), float(i * 4 + 3));
|
||||
cbufferdata[bindOffset + i] =
|
||||
Vec4f(float(i * 4 + 0), float(i * 4 + 1), float(i * 4 + 2), float(i * 4 + 3));
|
||||
|
||||
RootData rootData = {};
|
||||
|
||||
@@ -366,9 +372,11 @@ float4 main() : SV_Target0
|
||||
IASetVertexBuffer(cmd, vb, sizeof(DefaultA2V), 0);
|
||||
cmd->SetPipelineState(pso);
|
||||
cmd->SetGraphicsRootSignature(sig);
|
||||
cmd->SetGraphicsRootConstantBufferView(0, cb->GetGPUVirtualAddress());
|
||||
cmd->SetGraphicsRootConstantBufferView(
|
||||
0, cb->GetGPUVirtualAddress() + bindOffset * sizeof(Vec4f));
|
||||
cmd->SetGraphicsRoot32BitConstants(1, sizeof(rootData) / sizeof(uint32_t), &rootData, 0);
|
||||
cmd->SetGraphicsRootConstantBufferView(2, cb->GetGPUVirtualAddress() + 256);
|
||||
cmd->SetGraphicsRootConstantBufferView(
|
||||
2, cb->GetGPUVirtualAddress() + bindOffset * sizeof(Vec4f) + 256);
|
||||
|
||||
RSSetViewport(cmd, {0.0f, 0.0f, (float)screenWidth, (float)screenHeight, 0.0f, 1.0f});
|
||||
RSSetScissorRect(cmd, {0, 0, screenWidth, screenHeight});
|
||||
|
||||
@@ -360,10 +360,16 @@ void main()
|
||||
|
||||
GLuint program = MakeProgram(common + vertex, common + pixel);
|
||||
|
||||
Vec4f cbufferdata[1024];
|
||||
const size_t bindOffset = 16;
|
||||
|
||||
Vec4f cbufferdata[1024 + bindOffset];
|
||||
|
||||
for(int i = 0; i < bindOffset; i++)
|
||||
cbufferdata[i] = Vec4f(-99.9f, -88.8f, -77.7f, -66.6f);
|
||||
|
||||
for(int i = 0; i < 1024; i++)
|
||||
cbufferdata[i] = Vec4f(float(i * 4 + 0), float(i * 4 + 1), float(i * 4 + 2), float(i * 4 + 3));
|
||||
cbufferdata[bindOffset + i] =
|
||||
Vec4f(float(i * 4 + 0), float(i * 4 + 1), float(i * 4 + 2), float(i * 4 + 3));
|
||||
|
||||
GLuint cb = MakeBuffer();
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, cb);
|
||||
@@ -389,7 +395,7 @@ void main()
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
glBindVertexArray(vao);
|
||||
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, 0, cb);
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, 0, cb, bindOffset * sizeof(Vec4f), 1024 * sizeof(Vec4f));
|
||||
|
||||
glUseProgram(program);
|
||||
|
||||
|
||||
@@ -622,10 +622,16 @@ float4 main() : SV_Target0
|
||||
|
||||
vb.upload(DefaultTri);
|
||||
|
||||
Vec4f cbufferdata[512];
|
||||
const size_t bindOffset = 16;
|
||||
|
||||
Vec4f cbufferdata[512 + bindOffset];
|
||||
|
||||
for(int i = 0; i < bindOffset; i++)
|
||||
cbufferdata[i] = Vec4f(-99.9f, -88.8f, -77.7f, -66.6f);
|
||||
|
||||
for(int i = 0; i < 512; i++)
|
||||
cbufferdata[i] = Vec4f(float(i * 4 + 0), float(i * 4 + 1), float(i * 4 + 2), float(i * 4 + 3));
|
||||
cbufferdata[i + bindOffset] =
|
||||
Vec4f(float(i * 4 + 0), float(i * 4 + 1), float(i * 4 + 2), float(i * 4 + 3));
|
||||
|
||||
AllocatedBuffer cb(
|
||||
this, vkh::BufferCreateInfo(sizeof(cbufferdata), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT |
|
||||
@@ -638,8 +644,9 @@ float4 main() : SV_Target0
|
||||
|
||||
vkh::updateDescriptorSets(
|
||||
device, {
|
||||
vkh::WriteDescriptorSet(descset, 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
{vkh::DescriptorBufferInfo(cb.buffer)}),
|
||||
vkh::WriteDescriptorSet(
|
||||
descset, 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
{vkh::DescriptorBufferInfo(cb.buffer, bindOffset * sizeof(Vec4f))}),
|
||||
});
|
||||
|
||||
while(Running())
|
||||
|
||||
Reference in New Issue
Block a user