diff options
author | omnisci3nce <omniscient.oce@gmail.com> | 2024-07-17 23:12:42 +1000 |
---|---|---|
committer | omnisci3nce <omniscient.oce@gmail.com> | 2024-07-17 23:12:42 +1000 |
commit | c3737fff1be704e14a2bada69bbf8a6709c5f670 (patch) | |
tree | aa2225901f26598b07855a65a944354fbedc40b1 /src/ral | |
parent | f8641a5cc4c8baf1f0a7be3685afc219d90143d9 (diff) |
wip shader layouts for common stuff
Diffstat (limited to 'src/ral')
-rw-r--r-- | src/ral/backends/opengl/backend_opengl.c | 18 | ||||
-rw-r--r-- | src/ral/ral_impl.h | 1 | ||||
-rw-r--r-- | src/ral/ral_types.h | 8 |
3 files changed, 25 insertions, 2 deletions
diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c index cbfd855..ecf0e80 100644 --- a/src/ral/backends/opengl/backend_opengl.c +++ b/src/ral/backends/opengl/backend_opengl.c @@ -174,7 +174,7 @@ BufferHandle GPU_BufferCreate(u64 size, GPU_BufferType buf_type, GPU_BufferFlags const void* data) { // "allocating" the cpu-side buffer struct BufferHandle handle; - GPU_Buffer* buffer = Buffer_pool_alloc(&context.resource_pools, &handle); + GPU_Buffer* buffer = Buffer_pool_alloc(&context.resource_pools->buffers, &handle); buffer->size = size; buffer->vao = 0; @@ -269,6 +269,22 @@ TextureHandle GPU_TextureCreate(TextureDesc desc, bool create_view, const void* return handle; } +GPU_Texture* GPU_TextureAlloc(TextureHandle* out_handle) { + TextureHandle handle; + GPU_Texture* texture = Texture_pool_alloc(&context.resource_pools->textures, &handle); + DEBUG("Allocated texture with handle %d", handle.raw); + + GLuint gl_texture_id; + glGenTextures(1, &gl_texture_id); + texture->id = gl_texture_id; + + if (out_handle != NULL) { + *out_handle = handle; + } + + return texture; +} + void GPU_TextureDestroy(TextureHandle handle) { glDeleteTextures(1, &handle.raw); } // TODO: void GPU_TextureUpload(TextureHandle handle, size_t n_bytes, const void* data) diff --git a/src/ral/ral_impl.h b/src/ral/ral_impl.h index 7cc9459..9343962 100644 --- a/src/ral/ral_impl.h +++ b/src/ral/ral_impl.h @@ -52,6 +52,7 @@ PUB void GPU_BufferUpload(BufferHandle buffer, size_t n_bytes, const void* data) // --- Textures PUB TextureHandle GPU_TextureCreate(TextureDesc desc, bool create_view, const void* data); +PUB GPU_Texture* GPU_TextureAlloc(TextureHandle* out_handle); PUB void GPU_TextureDestroy(TextureHandle handle); PUB void GPU_TextureUpload(TextureHandle handle, size_t n_bytes, const void* data); diff --git a/src/ral/ral_types.h b/src/ral/ral_types.h index ffcc2cd..092bb2b 100644 --- a/src/ral/ral_types.h +++ b/src/ral/ral_types.h @@ -55,6 +55,7 @@ typedef enum GPU_TextureType { typedef enum GPU_TextureFormat { TEXTURE_FORMAT_8_8_8_8_RGBA_UNORM, + TEXTURE_FORMAT_8_8_8_RGB_UNORM, TEXTURE_FORMAT_DEPTH_DEFAULT, TEXTURE_FORMAT_COUNT } GPU_TextureFormat; @@ -144,6 +145,11 @@ typedef struct VertexDescription { } VertexDescription; // --- Shaders +typedef enum PipelineKind { + PIPELINE_GRAPHICS, + PIPELINE_COMPUTE, +} PipelineKind; + typedef enum ShaderVisibility { VISIBILITY_VERTEX = 1 << 0, VISIBILITY_FRAGMENT = 1 << 1, @@ -164,7 +170,7 @@ typedef enum ShaderBindingKind { BINDING_BUFFER_ARRAY, BINDING_TEXTURE, BINDING_TEXTURE_ARRAY, - // TODO: sampler + BINDING_SAMPLER, BINDING_COUNT } ShaderBindingKind; |