Route shader runtime calls through renderer GL

This commit is contained in:
2026-06-03 06:53:51 +02:00
parent f20595aff6
commit acdaf3bb8e
6 changed files with 717 additions and 17 deletions

View File

@@ -883,6 +883,153 @@ pp::foundation::Status bind_opengl_sampler_object(
return pp::foundation::Status::success();
}
pp::foundation::Status use_opengl_program(
std::uint32_t program_id,
OpenGlProgramUseDispatch dispatch) noexcept
{
if (dispatch.use_program == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL program use dispatch callback must not be null");
}
dispatch.use_program(program_id);
return pp::foundation::Status::success();
}
pp::foundation::Status delete_opengl_program(
std::uint32_t program_id,
OpenGlProgramDeleteDispatch dispatch) noexcept
{
if (dispatch.use_program == nullptr || dispatch.delete_program == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL program delete dispatch callbacks must not be null");
}
if (program_id == 0U) {
return pp::foundation::Status::success();
}
dispatch.use_program(default_framebuffer_id());
dispatch.delete_program(program_id);
return pp::foundation::Status::success();
}
pp::foundation::Status set_opengl_uniform_vec4(
std::int32_t location,
const float* values,
OpenGlUniformVec4Dispatch dispatch) noexcept
{
if (dispatch.uniform_4fv == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL vec4 uniform dispatch callback must not be null");
}
if (values == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL vec4 uniform values must not be null");
}
dispatch.uniform_4fv(location, 1, values);
return pp::foundation::Status::success();
}
pp::foundation::Status set_opengl_uniform_vec3(
std::int32_t location,
const float* values,
OpenGlUniformVec3Dispatch dispatch) noexcept
{
if (dispatch.uniform_3fv == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL vec3 uniform dispatch callback must not be null");
}
if (values == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL vec3 uniform values must not be null");
}
dispatch.uniform_3fv(location, 1, values);
return pp::foundation::Status::success();
}
pp::foundation::Status set_opengl_uniform_vec2(
std::int32_t location,
const float* values,
OpenGlUniformVec2Dispatch dispatch) noexcept
{
if (dispatch.uniform_2fv == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL vec2 uniform dispatch callback must not be null");
}
if (values == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL vec2 uniform values must not be null");
}
dispatch.uniform_2fv(location, 1, values);
return pp::foundation::Status::success();
}
pp::foundation::Status set_opengl_uniform_mat4(
std::int32_t location,
const float* values,
OpenGlUniformMat4Dispatch dispatch) noexcept
{
if (dispatch.uniform_matrix_4fv == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL mat4 uniform dispatch callback must not be null");
}
if (values == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL mat4 uniform values must not be null");
}
dispatch.uniform_matrix_4fv(
location,
1,
static_cast<std::uint8_t>(matrix_uniform_not_transposed()),
values);
return pp::foundation::Status::success();
}
pp::foundation::Status set_opengl_uniform_int(
std::int32_t location,
std::int32_t value,
OpenGlUniformIntDispatch dispatch) noexcept
{
if (dispatch.uniform_1i == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL int uniform dispatch callback must not be null");
}
dispatch.uniform_1i(location, value);
return pp::foundation::Status::success();
}
pp::foundation::Status set_opengl_uniform_float(
std::int32_t location,
float value,
OpenGlUniformFloatDispatch dispatch) noexcept
{
if (dispatch.uniform_1f == nullptr) {
return pp::foundation::Status::invalid_argument("OpenGL float uniform dispatch callback must not be null");
}
dispatch.uniform_1f(location, value);
return pp::foundation::Status::success();
}
pp::foundation::Result<std::int32_t> get_opengl_attribute_location(
std::uint32_t program_id,
const char* attribute_name,
OpenGlAttributeLocationDispatch dispatch) noexcept
{
if (dispatch.get_attrib_location == nullptr) {
return pp::foundation::Result<std::int32_t>::failure(
pp::foundation::Status::invalid_argument(
"OpenGL attribute-location dispatch callback must not be null"));
}
if (program_id == 0U || attribute_name == nullptr || attribute_name[0] == '\0') {
return pp::foundation::Result<std::int32_t>::failure(
pp::foundation::Status::invalid_argument("OpenGL attribute-location parameters are invalid"));
}
return pp::foundation::Result<std::int32_t>::success(
dispatch.get_attrib_location(program_id, attribute_name));
}
std::uint32_t extension_count_query() noexcept
{
return gl_num_extensions;