some updates
This commit is contained in:
parent
fd310560f9
commit
351311bb66
26 changed files with 26 additions and 58 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,5 +4,3 @@ build/
|
|||
|
||||
# MacOS Cache
|
||||
.DS_Store
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <pch.h>
|
||||
|
||||
SDL_GPUCommandBuffer* CommandBufferAcquire(SDL_GPUDevice* device) {
|
||||
assert(device != NULL);
|
||||
SDL_assert(device != NULL);
|
||||
|
||||
SDL_GPUCommandBuffer* command_buffer = SDL_AcquireGPUCommandBuffer(device);
|
||||
if(command_buffer == NULL) {
|
||||
|
@ -13,7 +13,7 @@ SDL_GPUCommandBuffer* CommandBufferAcquire(SDL_GPUDevice* device) {
|
|||
}
|
||||
|
||||
bool CommandBufferSubmit(SDL_GPUCommandBuffer* command_buffer) {
|
||||
assert(command_buffer != NULL);
|
||||
SDL_assert(command_buffer != NULL);
|
||||
|
||||
bool success = SDL_SubmitGPUCommandBuffer(command_buffer);
|
||||
if(!success) {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#include <SDL3/SDL_gpu.h>
|
||||
#include <pch.h>
|
||||
|
||||
SDL_GPUGraphicsPipeline* GraphicsPipelineCreate(SDL_GPUDevice* device, SDL_Window* window,
|
||||
SDL_GPUShader* vertex_shader, SDL_GPUShader* fragment_shader) {
|
||||
assert(device != NULL);
|
||||
assert(window != NULL);
|
||||
assert(vertex_shader != NULL);
|
||||
assert(fragment_shader != NULL);
|
||||
SDL_assert(device != NULL);
|
||||
SDL_assert(window != NULL);
|
||||
SDL_assert(vertex_shader != NULL);
|
||||
SDL_assert(fragment_shader != NULL);
|
||||
|
||||
SDL_GPUGraphicsPipeline* pipeline = SDL_CreateGPUGraphicsPipeline(device,
|
||||
&(SDL_GPUGraphicsPipelineCreateInfo){
|
||||
|
@ -25,14 +24,8 @@ SDL_GPUGraphicsPipeline* GraphicsPipelineCreate(SDL_GPUDevice* device, SDL_Windo
|
|||
.slot = 0,
|
||||
.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX,
|
||||
.instance_step_rate = 0,
|
||||
.pitch = sizeof(float) * 3,
|
||||
.pitch = sizeof(Vertex),
|
||||
},
|
||||
{
|
||||
.slot = 1,
|
||||
.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX,
|
||||
.instance_step_rate = 0,
|
||||
.pitch = sizeof(float) * 3,
|
||||
}
|
||||
},
|
||||
.num_vertex_attributes = 2,
|
||||
.vertex_attributes = (SDL_GPUVertexAttribute[]){
|
||||
|
@ -40,13 +33,13 @@ SDL_GPUGraphicsPipeline* GraphicsPipelineCreate(SDL_GPUDevice* device, SDL_Windo
|
|||
.buffer_slot = 0,
|
||||
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
|
||||
.location = 0,
|
||||
.offset = 0,
|
||||
.offset = offsetof(Vertex, pos),
|
||||
},
|
||||
{
|
||||
.buffer_slot = 1,
|
||||
.buffer_slot = 0,
|
||||
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
|
||||
.location = 1,
|
||||
.offset = 0,
|
||||
.offset = offsetof(Vertex, color),
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <pch.h>
|
||||
|
||||
SDL_GPUShader* ShaderLoad(SDL_GPUDevice* device, const char* filename, SDL_GPUShaderStage stage) {
|
||||
assert(device != NULL);
|
||||
SDL_assert(device != NULL);
|
||||
|
||||
FileData file = FileRead(filename);
|
||||
SDL_GPUShader* shader = SDL_CreateGPUShader(device,
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include <pch.h>
|
||||
|
||||
bool UploadToBuffer(SDL_GPUDevice* device, const void* data, size_t byte_size, SDL_GPUBuffer* buffer) {
|
||||
assert(device != NULL);
|
||||
assert(data != NULL);
|
||||
assert(buffer != NULL);
|
||||
SDL_assert(device != NULL);
|
||||
SDL_assert(data != NULL);
|
||||
SDL_assert(buffer != NULL);
|
||||
|
||||
SDL_GPUTransferBuffer* transfer_buffer = SDL_CreateGPUTransferBuffer(device,
|
||||
&(SDL_GPUTransferBufferCreateInfo){
|
||||
|
@ -28,10 +28,10 @@ bool UploadToBuffer(SDL_GPUDevice* device, const void* data, size_t byte_size, S
|
|||
SDL_UnmapGPUTransferBuffer(device, transfer_buffer);
|
||||
|
||||
SDL_GPUCommandBuffer* copy_command_buffer = CommandBufferAcquire(device);
|
||||
assert(copy_command_buffer != NULL);
|
||||
SDL_assert(copy_command_buffer != NULL);
|
||||
|
||||
SDL_GPUCopyPass* copy_pass = CopyPassBegin(copy_command_buffer);
|
||||
assert(copy_pass != NULL);
|
||||
SDL_assert(copy_pass != NULL);
|
||||
|
||||
SDL_UploadToGPUBuffer(copy_pass,
|
||||
&(SDL_GPUTransferBufferLocation){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <pch.h>
|
||||
|
||||
SDL_GPUCopyPass* CopyPassBegin(SDL_GPUCommandBuffer* copy_command_buffer) {
|
||||
assert(copy_command_buffer != NULL);
|
||||
SDL_assert(copy_command_buffer != NULL);
|
||||
|
||||
SDL_GPUCopyPass* copy_pass = SDL_BeginGPUCopyPass(copy_command_buffer);
|
||||
if(copy_pass == NULL) {
|
||||
|
@ -12,7 +12,7 @@ SDL_GPUCopyPass* CopyPassBegin(SDL_GPUCommandBuffer* copy_command_buffer) {
|
|||
}
|
||||
|
||||
void CopyPassEnd(SDL_GPUCopyPass* copy_pass) {
|
||||
assert(copy_pass != NULL);
|
||||
SDL_assert(copy_pass != NULL);
|
||||
|
||||
SDL_EndGPUCopyPass(copy_pass);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ int main(int argc, char** argv) {
|
|||
InitSystems();
|
||||
|
||||
SDL_GPUDevice* device = DeviceCreate();
|
||||
assert(device != NULL);
|
||||
SDL_assert(device != NULL);
|
||||
|
||||
SDL_Window* window = SDL_CreateWindow("Brimstone", 800, 600, 0);
|
||||
if(window == NULL) {
|
||||
|
@ -14,21 +14,10 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
SDL_ClaimWindowForGPUDevice(device, window);
|
||||
|
||||
/*Vertex vertices[] = {
|
||||
Vertex vertices[] = {
|
||||
{ -0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f },
|
||||
{ 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f },
|
||||
};*/
|
||||
float vertices[3][3] = {
|
||||
{ -0.5f, -0.5f, 0.0f },
|
||||
{ 0.5f, -0.5f, 0.0f },
|
||||
{ 0.0f, 0.5f, 0.0f },
|
||||
};
|
||||
|
||||
float colors[3][3] = {
|
||||
{ 1.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 1.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 1.0f },
|
||||
};
|
||||
|
||||
SDL_GPUBuffer* vertex_buffer = SDL_CreateGPUBuffer(device,
|
||||
|
@ -38,26 +27,17 @@ int main(int argc, char** argv) {
|
|||
});
|
||||
|
||||
bool upload_successful = UploadToBuffer(device, vertices, sizeof(vertices), vertex_buffer);
|
||||
assert(upload_successful);
|
||||
|
||||
SDL_GPUBuffer* color_buffer = SDL_CreateGPUBuffer(device,
|
||||
&(SDL_GPUBufferCreateInfo){
|
||||
.usage = SDL_GPU_BUFFERUSAGE_VERTEX,
|
||||
.size = sizeof(colors),
|
||||
});
|
||||
|
||||
upload_successful = UploadToBuffer(device, colors, sizeof(colors), color_buffer);
|
||||
assert(upload_successful);
|
||||
SDL_assert(upload_successful);
|
||||
|
||||
SDL_GPUShader* vertex_shader = ShaderLoad(device, "shader.vert.spv", SDL_GPU_SHADERSTAGE_VERTEX);
|
||||
assert(vertex_shader != NULL);
|
||||
SDL_assert(vertex_shader != NULL);
|
||||
|
||||
SDL_GPUShader* fragment_shader = ShaderLoad(device, "shader.frag.spv", SDL_GPU_SHADERSTAGE_FRAGMENT);
|
||||
assert(fragment_shader != NULL);
|
||||
SDL_assert(fragment_shader != NULL);
|
||||
|
||||
SDL_GPUGraphicsPipeline* pipeline = GraphicsPipelineCreate(
|
||||
device, window, vertex_shader, fragment_shader);
|
||||
assert(pipeline != NULL);
|
||||
SDL_assert(pipeline != NULL);
|
||||
|
||||
bool running = true;
|
||||
SDL_Event event;
|
||||
|
@ -99,12 +79,8 @@ int main(int argc, char** argv) {
|
|||
.buffer = vertex_buffer,
|
||||
.offset = 0,
|
||||
},
|
||||
{
|
||||
.buffer = color_buffer,
|
||||
.offset = 0,
|
||||
},
|
||||
},
|
||||
2);
|
||||
1);
|
||||
SDL_DrawGPUPrimitives(render_pass, 3, 1, 0, 0);
|
||||
|
||||
SDL_EndGPURenderPass(render_pass);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_assert.h>
|
||||
#include <SDL3/SDL_error.h>
|
||||
#include <SDL3/SDL_events.h>
|
||||
#include <SDL3/SDL_gpu.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue