Route cube textures and samplers through renderer GL

This commit is contained in:
2026-06-03 06:46:06 +02:00
parent 779d6b0387
commit f20595aff6
6 changed files with 714 additions and 59 deletions

View File

@@ -119,6 +119,13 @@ struct OpenGlTexture2DAllocation {
const void* data = nullptr;
};
struct OpenGlTextureCubeAllocation {
std::int32_t resolution = 0;
std::int32_t internal_format = 0;
std::uint32_t pixel_format = 0;
std::uint32_t component_type = 0;
};
struct OpenGlTexture2DUpdate {
std::uint32_t texture_id = 0;
std::int32_t width = 0;
@@ -216,6 +223,14 @@ using OpenGlUseProgramFn = void (*)(std::uint32_t program) noexcept;
using OpenGlBindFramebufferFn = void (*)(std::uint32_t target, std::uint32_t framebuffer) noexcept;
using OpenGlBindTextureFn = void (*)(std::uint32_t target, std::uint32_t texture) noexcept;
using OpenGlBindSamplerFn = void (*)(std::uint32_t unit, std::uint32_t sampler) noexcept;
using OpenGlSamplerParameteriFn = void (*)(
std::uint32_t sampler,
std::uint32_t parameter,
std::int32_t value) noexcept;
using OpenGlSamplerParameterfvFn = void (*)(
std::uint32_t sampler,
std::uint32_t parameter,
const float* values) noexcept;
using OpenGlGenObjectsFn = void (*)(std::uint32_t count, std::uint32_t* ids) noexcept;
using OpenGlDeleteObjectsFn = void (*)(std::uint32_t count, const std::uint32_t* ids) noexcept;
using OpenGlTexImage2DFn = void (*)(
@@ -349,6 +364,12 @@ struct OpenGlTexture2DDeleteDispatch {
OpenGlDeleteObjectsFn delete_textures = nullptr;
};
struct OpenGlTextureCubeAllocationDispatch {
OpenGlGenObjectsFn gen_textures = nullptr;
OpenGlBindTextureFn bind_texture = nullptr;
OpenGlTexImage2DFn tex_image_2d = nullptr;
};
struct OpenGlTexture2DBindDispatch {
OpenGlBindTextureFn bind_texture = nullptr;
};
@@ -395,6 +416,23 @@ struct OpenGlFramebufferRestoreDispatch {
OpenGlBindFramebufferFn bind_framebuffer = nullptr;
};
struct OpenGlSamplerCreateDispatch {
OpenGlGenObjectsFn gen_samplers = nullptr;
OpenGlSamplerParameteriFn sampler_parameter_i = nullptr;
};
struct OpenGlSamplerParameterDispatch {
OpenGlSamplerParameteriFn sampler_parameter_i = nullptr;
};
struct OpenGlSamplerBorderDispatch {
OpenGlSamplerParameterfvFn sampler_parameter_fv = nullptr;
};
struct OpenGlSamplerBindDispatch {
OpenGlBindSamplerFn bind_sampler = nullptr;
};
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
std::span<const std::string_view> extensions,
OpenGlRuntime runtime) noexcept;
@@ -433,9 +471,18 @@ struct OpenGlFramebufferRestoreDispatch {
[[nodiscard]] pp::foundation::Status delete_opengl_texture_2d(
std::uint32_t texture_id,
OpenGlTexture2DDeleteDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Status delete_opengl_texture_objects(
std::span<const std::uint32_t> texture_ids,
OpenGlTexture2DDeleteDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Result<std::uint32_t> allocate_opengl_texture_cube(
OpenGlTextureCubeAllocation allocation,
OpenGlTextureCubeAllocationDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Status bind_opengl_texture_2d(
std::uint32_t texture_id,
OpenGlTexture2DBindDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Status bind_opengl_texture_cube(
std::uint32_t texture_id,
OpenGlTexture2DBindDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Status update_opengl_texture_2d(
OpenGlTexture2DUpdate update,
OpenGlTexture2DUpdateDispatch dispatch) noexcept;
@@ -457,6 +504,22 @@ struct OpenGlFramebufferRestoreDispatch {
[[nodiscard]] pp::foundation::Status restore_opengl_framebuffer_binding(
OpenGlFramebufferBindingState binding,
OpenGlFramebufferRestoreDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Result<std::uint32_t> create_opengl_sampler(
std::span<const OpenGlTextureParameter> parameters,
OpenGlSamplerCreateDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Status set_opengl_sampler_parameters(
std::uint32_t sampler_id,
std::span<const OpenGlTextureParameter> parameters,
OpenGlSamplerParameterDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Status set_opengl_sampler_border_color(
std::uint32_t sampler_id,
std::uint32_t parameter,
const float* rgba,
OpenGlSamplerBorderDispatch dispatch) noexcept;
[[nodiscard]] pp::foundation::Status bind_opengl_sampler_object(
std::uint32_t unit,
std::uint32_t sampler_id,
OpenGlSamplerBindDispatch dispatch) noexcept;
[[nodiscard]] std::uint32_t extension_count_query() noexcept;
[[nodiscard]] std::uint32_t extension_string_name() noexcept;