Part generated by gemini with antigravity.

Converted to bindless first step
This commit is contained in:
2026-01-11 17:54:57 -05:00
parent bd45cacc6c
commit 8a23ae72fe
18 changed files with 481 additions and 122 deletions

View File

@@ -43,6 +43,12 @@ namespace
const char* GameFunctionTable[] = { "GameInit", "GameShutdown", "GameUpdate" };
} // namespace
struct Vertex
{
float Position[2];
float Color[4];
};
void JulietApplication::Init()
{
Log(LogLevel::Message, LogCategory::Tool, "Initializing Juliet Application...");
@@ -98,6 +104,17 @@ void JulietApplication::Init()
Running = false;
}
// Create Buffers
BufferCreateInfo bufferCI = {};
bufferCI.Size = 256;
bufferCI.Usage = BufferUsage::StructuredBuffer; // Changed to StructuredBuffer As Requested
ConstantBuffer = CreateGraphicsBuffer(GraphicsDevice, bufferCI);
TransferBufferCreateInfo transferCI = {};
transferCI.Size = 256;
transferCI.Usage = TransferBufferUsage::Upload;
TransferBuffer = CreateGraphicsTransferBuffer(GraphicsDevice, transferCI);
if (vertexShader)
{
DestroyShader(GraphicsDevice, vertexShader);
@@ -138,6 +155,14 @@ void JulietApplication::Shutdown()
{
DestroyGraphicsPipeline(GraphicsDevice, GraphicsPipeline);
}
if (ConstantBuffer)
{
DestroyGraphicsBuffer(GraphicsDevice, ConstantBuffer);
}
if (TransferBuffer)
{
DestroyGraphicsTransferBuffer(GraphicsDevice, TransferBuffer);
}
if (MainWindow && GraphicsDevice)
{
@@ -254,9 +279,38 @@ void JulietApplication::Update()
colorTargetInfo.LoadOperation = LoadOperation::Clear;
colorTargetInfo.StoreOperation = StoreOperation::Store;
if (ConstantBuffer && TransferBuffer)
{
void* ptr = MapGraphicsTransferBuffer(GraphicsDevice, TransferBuffer);
if (ptr)
{
Vertex* vertices = static_cast<Vertex*>(ptr);
// Triangle 1
vertices[0] = { { -0.5f, -0.5f }, { 1.0f, 0.0f, 0.0f, 1.0f } }; // Red
vertices[1] = { { 0.0f, 0.5f }, { 0.0f, 1.0f, 0.0f, 1.0f } }; // Green
vertices[2] = { { 0.5f, -0.5f }, { 0.0f, 0.0f, 1.0f, 1.0f } }; // Blue
// Triangle 2
vertices[3] = { { -0.5f, 0.5f }, { 1.0f, 1.0f, 0.0f, 1.0f } }; // Yellow
vertices[4] = { { 0.0f, 0.8f }, { 0.0f, 1.0f, 1.0f, 1.0f } }; // Cyan
vertices[5] = { { 0.5f, 0.5f }, { 1.0f, 0.0f, 1.0f, 1.0f } }; // Magenta
UnmapGraphicsTransferBuffer(GraphicsDevice, TransferBuffer);
}
CopyBuffer(cmdList, ConstantBuffer, TransferBuffer, 256);
TransitionBufferToReadable(cmdList, ConstantBuffer);
}
RenderPass* renderPass = BeginRenderPass(cmdList, colorTargetInfo);
BindGraphicsPipeline(renderPass, GraphicsPipeline);
DrawPrimitives(renderPass, 3, 1, 0, 0);
// Pass descriptor index via Push Constants AFTER finding the pipeline (RootSignature)
uint32 descriptorIndex = GetDescriptorIndex(GraphicsDevice, ConstantBuffer);
SetPushConstants(cmdList, ShaderStage::Vertex, 0, 1, &descriptorIndex);
DrawPrimitives(renderPass, 6, 1, 0, 0);
EndRenderPass(renderPass);
}