Compare commits
No commits in common. "c0b78452155f2ad468d5061a98d9976f98816a79" and "fd310560f9b153eb8a454cb65b627af7e3454d8c" have entirely different histories.
c0b7845215
...
fd310560f9
26 changed files with 57 additions and 27 deletions
BIN
.cache/clangd/index/command_buffer.h.80BF74E22FA9A8B1.idx
Normal file
BIN
.cache/clangd/index/command_buffer.h.80BF74E22FA9A8B1.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/copy_pass.h.75DC6BAB12A460E6.idx
Normal file
BIN
.cache/clangd/index/copy_pass.h.75DC6BAB12A460E6.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/device.c.6C259B36172A19C7.idx
Normal file
BIN
.cache/clangd/index/device.c.6C259B36172A19C7.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/device.h.17FFF3FE11DD7B5E.idx
Normal file
BIN
.cache/clangd/index/device.h.17FFF3FE11DD7B5E.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/device.h.5489FF8BB9CB1FFB.idx
Normal file
BIN
.cache/clangd/index/device.h.5489FF8BB9CB1FFB.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/file.c.CB50DC29A19B1694.idx
Normal file
BIN
.cache/clangd/index/file.c.CB50DC29A19B1694.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/file.h.9B3CB7460AC25849.idx
Normal file
BIN
.cache/clangd/index/file.h.9B3CB7460AC25849.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/init.h.5C86A0883D04E9FA.idx
Normal file
BIN
.cache/clangd/index/init.h.5C86A0883D04E9FA.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/io.c.83B1619B498EFDA2.idx
Normal file
BIN
.cache/clangd/index/io.c.83B1619B498EFDA2.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/io.h.A5F7786F8F198D59.idx
Normal file
BIN
.cache/clangd/index/io.h.A5F7786F8F198D59.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/main.c.360458CBCE130659.idx
Normal file
BIN
.cache/clangd/index/main.c.360458CBCE130659.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/main.c.FC90165D9662D1FF.idx
Normal file
BIN
.cache/clangd/index/main.c.FC90165D9662D1FF.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/pch.h.FAF6765EBEF7A460.idx
Normal file
BIN
.cache/clangd/index/pch.h.FAF6765EBEF7A460.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/shaders.c.F6267E88DF3F57D6.idx
Normal file
BIN
.cache/clangd/index/shaders.c.F6267E88DF3F57D6.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/shaders.h.DC6F6E4EB912EE60.idx
Normal file
BIN
.cache/clangd/index/shaders.h.DC6F6E4EB912EE60.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/shaders.h.FB84043E831F692A.idx
Normal file
BIN
.cache/clangd/index/shaders.h.FB84043E831F692A.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/systems.h.4B3B0C8EFC1B6118.idx
Normal file
BIN
.cache/clangd/index/systems.h.4B3B0C8EFC1B6118.idx
Normal file
Binary file not shown.
BIN
.cache/clangd/index/upload.h.CC70961FD695C6D2.idx
Normal file
BIN
.cache/clangd/index/upload.h.CC70961FD695C6D2.idx
Normal file
Binary file not shown.
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,4 +5,4 @@ build/
|
|||
# MacOS Cache
|
||||
.DS_Store
|
||||
|
||||
.cache/
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <pch.h>
|
||||
|
||||
SDL_GPUCommandBuffer* CommandBufferAcquire(SDL_GPUDevice* device) {
|
||||
SDL_assert(device != NULL);
|
||||
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) {
|
||||
SDL_assert(command_buffer != NULL);
|
||||
assert(command_buffer != NULL);
|
||||
|
||||
bool success = SDL_SubmitGPUCommandBuffer(command_buffer);
|
||||
if(!success) {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#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) {
|
||||
SDL_assert(device != NULL);
|
||||
SDL_assert(window != NULL);
|
||||
SDL_assert(vertex_shader != NULL);
|
||||
SDL_assert(fragment_shader != NULL);
|
||||
assert(device != NULL);
|
||||
assert(window != NULL);
|
||||
assert(vertex_shader != NULL);
|
||||
assert(fragment_shader != NULL);
|
||||
|
||||
SDL_GPUGraphicsPipeline* pipeline = SDL_CreateGPUGraphicsPipeline(device,
|
||||
&(SDL_GPUGraphicsPipelineCreateInfo){
|
||||
|
@ -24,8 +25,14 @@ SDL_GPUGraphicsPipeline* GraphicsPipelineCreate(SDL_GPUDevice* device, SDL_Windo
|
|||
.slot = 0,
|
||||
.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX,
|
||||
.instance_step_rate = 0,
|
||||
.pitch = sizeof(Vertex),
|
||||
.pitch = sizeof(float) * 3,
|
||||
},
|
||||
{
|
||||
.slot = 1,
|
||||
.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX,
|
||||
.instance_step_rate = 0,
|
||||
.pitch = sizeof(float) * 3,
|
||||
}
|
||||
},
|
||||
.num_vertex_attributes = 2,
|
||||
.vertex_attributes = (SDL_GPUVertexAttribute[]){
|
||||
|
@ -33,13 +40,13 @@ SDL_GPUGraphicsPipeline* GraphicsPipelineCreate(SDL_GPUDevice* device, SDL_Windo
|
|||
.buffer_slot = 0,
|
||||
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
|
||||
.location = 0,
|
||||
.offset = offsetof(Vertex, pos),
|
||||
.offset = 0,
|
||||
},
|
||||
{
|
||||
.buffer_slot = 0,
|
||||
.buffer_slot = 1,
|
||||
.format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3,
|
||||
.location = 1,
|
||||
.offset = offsetof(Vertex, color),
|
||||
.offset = 0,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <pch.h>
|
||||
|
||||
SDL_GPUShader* ShaderLoad(SDL_GPUDevice* device, const char* filename, SDL_GPUShaderStage stage) {
|
||||
SDL_assert(device != NULL);
|
||||
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) {
|
||||
SDL_assert(device != NULL);
|
||||
SDL_assert(data != NULL);
|
||||
SDL_assert(buffer != NULL);
|
||||
assert(device != NULL);
|
||||
assert(data != NULL);
|
||||
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);
|
||||
SDL_assert(copy_command_buffer != NULL);
|
||||
assert(copy_command_buffer != NULL);
|
||||
|
||||
SDL_GPUCopyPass* copy_pass = CopyPassBegin(copy_command_buffer);
|
||||
SDL_assert(copy_pass != NULL);
|
||||
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) {
|
||||
SDL_assert(copy_command_buffer != NULL);
|
||||
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) {
|
||||
SDL_assert(copy_pass != NULL);
|
||||
assert(copy_pass != NULL);
|
||||
|
||||
SDL_EndGPUCopyPass(copy_pass);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ int main(int argc, char** argv) {
|
|||
InitSystems();
|
||||
|
||||
SDL_GPUDevice* device = DeviceCreate();
|
||||
SDL_assert(device != NULL);
|
||||
assert(device != NULL);
|
||||
|
||||
SDL_Window* window = SDL_CreateWindow("Brimstone", 800, 600, 0);
|
||||
if(window == NULL) {
|
||||
|
@ -14,10 +14,21 @@ 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,
|
||||
|
@ -27,17 +38,26 @@ int main(int argc, char** argv) {
|
|||
});
|
||||
|
||||
bool upload_successful = UploadToBuffer(device, vertices, sizeof(vertices), vertex_buffer);
|
||||
SDL_assert(upload_successful);
|
||||
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_GPUShader* vertex_shader = ShaderLoad(device, "shader.vert.spv", SDL_GPU_SHADERSTAGE_VERTEX);
|
||||
SDL_assert(vertex_shader != NULL);
|
||||
assert(vertex_shader != NULL);
|
||||
|
||||
SDL_GPUShader* fragment_shader = ShaderLoad(device, "shader.frag.spv", SDL_GPU_SHADERSTAGE_FRAGMENT);
|
||||
SDL_assert(fragment_shader != NULL);
|
||||
assert(fragment_shader != NULL);
|
||||
|
||||
SDL_GPUGraphicsPipeline* pipeline = GraphicsPipelineCreate(
|
||||
device, window, vertex_shader, fragment_shader);
|
||||
SDL_assert(pipeline != NULL);
|
||||
assert(pipeline != NULL);
|
||||
|
||||
bool running = true;
|
||||
SDL_Event event;
|
||||
|
@ -79,8 +99,12 @@ int main(int argc, char** argv) {
|
|||
.buffer = vertex_buffer,
|
||||
.offset = 0,
|
||||
},
|
||||
{
|
||||
.buffer = color_buffer,
|
||||
.offset = 0,
|
||||
},
|
||||
1);
|
||||
},
|
||||
2);
|
||||
SDL_DrawGPUPrimitives(render_pass, 3, 1, 0, 0);
|
||||
|
||||
SDL_EndGPURenderPass(render_pass);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#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