Map renderer depth state to OpenGL
This commit is contained in:
@@ -217,7 +217,8 @@ Known local toolchain state:
|
|||||||
by legacy `Shader` creation also live here. Renderer API blend factor/op to
|
by legacy `Shader` creation also live here. Renderer API blend factor/op to
|
||||||
OpenGL token mapping is tested here with explicit support flags so `GL_ZERO`
|
OpenGL token mapping is tested here with explicit support flags so `GL_ZERO`
|
||||||
stays distinguishable from unsupported enum values. Renderer API blend-state
|
stays distinguishable from unsupported enum values. Renderer API blend-state
|
||||||
color-write masks and depth compare-op to OpenGL depth-function mapping are
|
color-write masks, depth compare-op to OpenGL depth-function mapping, and
|
||||||
|
aggregate renderer API depth-state to OpenGL enable/write/compare mapping are
|
||||||
tested here too. `Shader` no longer spells GL enum
|
tested here too. `Shader` no longer spells GL enum
|
||||||
names directly. It also owns the PanoPainter shader uniform catalog and legacy hash
|
names directly. It also owns the PanoPainter shader uniform catalog and legacy hash
|
||||||
mapping used by `Shader` active-uniform discovery and the uniform uniqueness
|
mapping used by `Shader` active-uniform discovery and the uniform uniqueness
|
||||||
|
|||||||
@@ -474,7 +474,8 @@ count query, and matrix-uniform transpose token also live in `pp_renderer_gl`
|
|||||||
and are consumed by legacy `Shader` creation. Renderer API blend factor/op to
|
and are consumed by legacy `Shader` creation. Renderer API blend factor/op to
|
||||||
OpenGL token mapping also lives in `pp_renderer_gl`, with explicit support flags
|
OpenGL token mapping also lives in `pp_renderer_gl`, with explicit support flags
|
||||||
so `GL_ZERO` remains distinguishable from unsupported enum values. Renderer API
|
so `GL_ZERO` remains distinguishable from unsupported enum values. Renderer API
|
||||||
blend-state color-write masks and depth compare-op to OpenGL depth-function
|
blend-state color-write masks, depth compare-op to OpenGL depth-function
|
||||||
|
mapping, and aggregate renderer API depth-state to OpenGL enable/write/compare
|
||||||
mapping also live in `pp_renderer_gl`. Shader uniform hashing, catalog
|
mapping also live in `pp_renderer_gl`. Shader uniform hashing, catalog
|
||||||
validation, active-uniform mapping, and the legacy uniform uniqueness check now
|
validation, active-uniform mapping, and the legacy uniform uniqueness check now
|
||||||
delegate to `pp_renderer_gl` as well. `Shader` no longer spells GL enum names
|
delegate to `pp_renderer_gl` as well. `Shader` no longer spells GL enum names
|
||||||
|
|||||||
@@ -733,6 +733,17 @@ OpenGlEnumMapping compare_function_for_renderer_compare_op(pp::renderer::Compare
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenGlDepthState depth_state_for_renderer_depth_state(pp::renderer::DepthState state) noexcept
|
||||||
|
{
|
||||||
|
const auto compare_function = compare_function_for_renderer_compare_op(state.compare);
|
||||||
|
return OpenGlDepthState {
|
||||||
|
.test_enabled = state.test_enabled ? gl_boolean_true : gl_boolean_false,
|
||||||
|
.write_enabled = state.write_enabled ? gl_boolean_true : gl_boolean_false,
|
||||||
|
.compare_function = compare_function.value,
|
||||||
|
.supported = compare_function.supported,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
std::uint32_t scissor_test_state() noexcept
|
std::uint32_t scissor_test_state() noexcept
|
||||||
{
|
{
|
||||||
return gl_scissor_test;
|
return gl_scissor_test;
|
||||||
|
|||||||
@@ -46,6 +46,13 @@ struct OpenGlColorWriteMask {
|
|||||||
std::uint8_t a = 0;
|
std::uint8_t a = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct OpenGlDepthState {
|
||||||
|
std::uint8_t test_enabled = 0;
|
||||||
|
std::uint8_t write_enabled = 0;
|
||||||
|
std::uint32_t compare_function = 0;
|
||||||
|
bool supported = false;
|
||||||
|
};
|
||||||
|
|
||||||
struct OpenGlReadbackFormat {
|
struct OpenGlReadbackFormat {
|
||||||
std::uint32_t pixel_format = 0;
|
std::uint32_t pixel_format = 0;
|
||||||
std::uint32_t component_type = 0;
|
std::uint32_t component_type = 0;
|
||||||
@@ -149,6 +156,8 @@ struct OpenGlWindowsWglContextConfig {
|
|||||||
[[nodiscard]] std::uint32_t depth_test_state() noexcept;
|
[[nodiscard]] std::uint32_t depth_test_state() noexcept;
|
||||||
[[nodiscard]] OpenGlEnumMapping compare_function_for_renderer_compare_op(
|
[[nodiscard]] OpenGlEnumMapping compare_function_for_renderer_compare_op(
|
||||||
pp::renderer::CompareOp op) noexcept;
|
pp::renderer::CompareOp op) noexcept;
|
||||||
|
[[nodiscard]] OpenGlDepthState depth_state_for_renderer_depth_state(
|
||||||
|
pp::renderer::DepthState state) noexcept;
|
||||||
[[nodiscard]] std::uint32_t scissor_test_state() noexcept;
|
[[nodiscard]] std::uint32_t scissor_test_state() noexcept;
|
||||||
[[nodiscard]] std::uint32_t program_point_size_state() noexcept;
|
[[nodiscard]] std::uint32_t program_point_size_state() noexcept;
|
||||||
[[nodiscard]] std::uint32_t line_smooth_state() noexcept;
|
[[nodiscard]] std::uint32_t line_smooth_state() noexcept;
|
||||||
|
|||||||
@@ -274,26 +274,31 @@ void maps_render_pass_clear_masks(pp::tests::Harness& h)
|
|||||||
{
|
{
|
||||||
const auto no_clear = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
const auto no_clear = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
||||||
.clear_color_enabled = false,
|
.clear_color_enabled = false,
|
||||||
|
.clear_color = {},
|
||||||
.clear_depth_enabled = false,
|
.clear_depth_enabled = false,
|
||||||
.clear_stencil_enabled = false,
|
.clear_stencil_enabled = false,
|
||||||
});
|
});
|
||||||
const auto color_only = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
const auto color_only = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
||||||
.clear_color_enabled = true,
|
.clear_color_enabled = true,
|
||||||
|
.clear_color = {},
|
||||||
.clear_depth_enabled = false,
|
.clear_depth_enabled = false,
|
||||||
.clear_stencil_enabled = false,
|
.clear_stencil_enabled = false,
|
||||||
});
|
});
|
||||||
const auto depth_only = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
const auto depth_only = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
||||||
.clear_color_enabled = false,
|
.clear_color_enabled = false,
|
||||||
|
.clear_color = {},
|
||||||
.clear_depth_enabled = true,
|
.clear_depth_enabled = true,
|
||||||
.clear_stencil_enabled = false,
|
.clear_stencil_enabled = false,
|
||||||
});
|
});
|
||||||
const auto stencil_only = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
const auto stencil_only = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
||||||
.clear_color_enabled = false,
|
.clear_color_enabled = false,
|
||||||
|
.clear_color = {},
|
||||||
.clear_depth_enabled = false,
|
.clear_depth_enabled = false,
|
||||||
.clear_stencil_enabled = true,
|
.clear_stencil_enabled = true,
|
||||||
});
|
});
|
||||||
const auto all_buffers = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
const auto all_buffers = pp::renderer::gl::clear_mask_for_render_pass(pp::renderer::RenderPassDesc {
|
||||||
.clear_color_enabled = true,
|
.clear_color_enabled = true,
|
||||||
|
.clear_color = {},
|
||||||
.clear_depth_enabled = true,
|
.clear_depth_enabled = true,
|
||||||
.clear_stencil_enabled = true,
|
.clear_stencil_enabled = true,
|
||||||
});
|
});
|
||||||
@@ -635,6 +640,37 @@ void maps_renderer_depth_compare_tokens(pp::tests::Harness& h)
|
|||||||
PP_EXPECT(h, invalid.value == 0U);
|
PP_EXPECT(h, invalid.value == 0U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void maps_renderer_depth_states(pp::tests::Harness& h)
|
||||||
|
{
|
||||||
|
const auto disabled = pp::renderer::gl::depth_state_for_renderer_depth_state(
|
||||||
|
pp::renderer::DepthState {});
|
||||||
|
const auto read_write = pp::renderer::gl::depth_state_for_renderer_depth_state(
|
||||||
|
pp::renderer::DepthState {
|
||||||
|
.test_enabled = true,
|
||||||
|
.write_enabled = true,
|
||||||
|
.compare = pp::renderer::CompareOp::greater,
|
||||||
|
});
|
||||||
|
const auto invalid_compare = pp::renderer::gl::depth_state_for_renderer_depth_state(
|
||||||
|
pp::renderer::DepthState {
|
||||||
|
.test_enabled = true,
|
||||||
|
.write_enabled = false,
|
||||||
|
.compare = static_cast<pp::renderer::CompareOp>(255U),
|
||||||
|
});
|
||||||
|
|
||||||
|
PP_EXPECT(h, disabled.supported);
|
||||||
|
PP_EXPECT(h, disabled.test_enabled == 0U);
|
||||||
|
PP_EXPECT(h, disabled.write_enabled == 0U);
|
||||||
|
PP_EXPECT(h, disabled.compare_function == 0x0203U);
|
||||||
|
PP_EXPECT(h, read_write.supported);
|
||||||
|
PP_EXPECT(h, read_write.test_enabled == 1U);
|
||||||
|
PP_EXPECT(h, read_write.write_enabled == 1U);
|
||||||
|
PP_EXPECT(h, read_write.compare_function == 0x0204U);
|
||||||
|
PP_EXPECT(h, !invalid_compare.supported);
|
||||||
|
PP_EXPECT(h, invalid_compare.test_enabled == 1U);
|
||||||
|
PP_EXPECT(h, invalid_compare.write_enabled == 0U);
|
||||||
|
PP_EXPECT(h, invalid_compare.compare_function == 0U);
|
||||||
|
}
|
||||||
|
|
||||||
void maps_windows_wgl_core_context_parameters(pp::tests::Harness& h)
|
void maps_windows_wgl_core_context_parameters(pp::tests::Harness& h)
|
||||||
{
|
{
|
||||||
const auto config = pp::renderer::gl::windows_wgl_core_context_3_3_config();
|
const auto config = pp::renderer::gl::windows_wgl_core_context_3_3_config();
|
||||||
@@ -768,6 +804,7 @@ int main()
|
|||||||
harness.run("maps_renderer_blend_state_tokens", maps_renderer_blend_state_tokens);
|
harness.run("maps_renderer_blend_state_tokens", maps_renderer_blend_state_tokens);
|
||||||
harness.run("maps_renderer_color_write_masks", maps_renderer_color_write_masks);
|
harness.run("maps_renderer_color_write_masks", maps_renderer_color_write_masks);
|
||||||
harness.run("maps_renderer_depth_compare_tokens", maps_renderer_depth_compare_tokens);
|
harness.run("maps_renderer_depth_compare_tokens", maps_renderer_depth_compare_tokens);
|
||||||
|
harness.run("maps_renderer_depth_states", maps_renderer_depth_states);
|
||||||
harness.run("maps_windows_wgl_core_context_parameters", maps_windows_wgl_core_context_parameters);
|
harness.run("maps_windows_wgl_core_context_parameters", maps_windows_wgl_core_context_parameters);
|
||||||
harness.run("rejects_invalid_shader_attribute_binding_catalogs", rejects_invalid_shader_attribute_binding_catalogs);
|
harness.run("rejects_invalid_shader_attribute_binding_catalogs", rejects_invalid_shader_attribute_binding_catalogs);
|
||||||
harness.run("exposes_shader_uniform_catalog", exposes_shader_uniform_catalog);
|
harness.run("exposes_shader_uniform_catalog", exposes_shader_uniform_catalog);
|
||||||
|
|||||||
Reference in New Issue
Block a user