Move Windows WGL context attributes to renderer gl
This commit is contained in:
@@ -231,6 +231,9 @@ Known local toolchain state:
|
|||||||
readback format/type, framebuffer copy targets, and renderbuffer/depth
|
readback format/type, framebuffer copy targets, and renderbuffer/depth
|
||||||
attachment parameters; `src/canvas.cpp` no longer contains raw `GL_*`
|
attachment parameters; `src/canvas.cpp` no longer contains raw `GL_*`
|
||||||
constants.
|
constants.
|
||||||
|
Windows desktop OpenGL context creation now consumes a tested
|
||||||
|
`windows_wgl_core_context_3_3_config()` catalog from `pp_renderer_gl` instead
|
||||||
|
of owning active WGL context/pixel-format attribute literals in `main.cpp`.
|
||||||
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
|
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
|
||||||
for the current headless component matrix; see DEBT-0007 for remaining app
|
for the current headless component matrix; see DEBT-0007 for remaining app
|
||||||
and platform triplet migration.
|
and platform triplet migration.
|
||||||
|
|||||||
@@ -776,6 +776,10 @@ Results:
|
|||||||
framebuffer copy targets, and renderbuffer/depth attachment parameters through
|
framebuffer copy targets, and renderbuffer/depth attachment parameters through
|
||||||
the renderer GL backend mapping; `src/canvas.cpp` no longer contains raw
|
the renderer GL backend mapping; `src/canvas.cpp` no longer contains raw
|
||||||
`GL_*` constants.
|
`GL_*` constants.
|
||||||
|
- Windows desktop OpenGL context creation now consumes a tested
|
||||||
|
`windows_wgl_core_context_3_3_config()` catalog from `pp_renderer_gl`, moving
|
||||||
|
the active WGL context/pixel-format attribute literals out of the platform
|
||||||
|
entrypoint.
|
||||||
- Known remaining warnings: legacy project/vendor diagnostics, Visual Studio
|
- Known remaining warnings: legacy project/vendor diagnostics, Visual Studio
|
||||||
vcpkg-manifest warning, `LNK4099` missing libyuv PDBs, and `LNK4098` runtime
|
vcpkg-manifest warning, `LNK4099` missing libyuv PDBs, and `LNK4098` runtime
|
||||||
library conflict from retained vendor binaries.
|
library conflict from retained vendor binaries.
|
||||||
|
|||||||
27
src/main.cpp
27
src/main.cpp
@@ -974,28 +974,7 @@ int main(int argc, char** argv)
|
|||||||
// If supported create a 3.3 context
|
// If supported create a 3.3 context
|
||||||
if (GLAD_WGL_ARB_create_context)
|
if (GLAD_WGL_ARB_create_context)
|
||||||
{
|
{
|
||||||
int contex_attribs[] =
|
const auto wgl_config = pp::renderer::gl::windows_wgl_core_context_3_3_config();
|
||||||
{
|
|
||||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
|
|
||||||
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
|
|
||||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
|
||||||
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
|
||||||
0
|
|
||||||
};
|
|
||||||
int pixel_attribs[] =
|
|
||||||
{
|
|
||||||
WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
|
|
||||||
WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
|
|
||||||
WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
|
|
||||||
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
|
|
||||||
WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
|
|
||||||
WGL_COLOR_BITS_ARB, 24,
|
|
||||||
WGL_DEPTH_BITS_ARB, 16,
|
|
||||||
//WGL_STENCIL_BITS_ARB, 8,
|
|
||||||
//WGL_SAMPLE_BUFFERS_ARB, 1, // Number of buffers (must be 1 at time of writing)
|
|
||||||
//WGL_SAMPLES_ARB, 4, // Number of samples
|
|
||||||
0
|
|
||||||
};
|
|
||||||
UINT numFormat;
|
UINT numFormat;
|
||||||
|
|
||||||
wglMakeCurrent(NULL, NULL);
|
wglMakeCurrent(NULL, NULL);
|
||||||
@@ -1007,9 +986,9 @@ int main(int argc, char** argv)
|
|||||||
(float)(clientRect.bottom - clientRect.top), 0, 0, hInst, 0);
|
(float)(clientRect.bottom - clientRect.top), 0, 0, hInst, 0);
|
||||||
|
|
||||||
hDC = GetDC(hWnd);
|
hDC = GetDC(hWnd);
|
||||||
wglChoosePixelFormatARB(hDC, pixel_attribs, nullptr, 1, &pxfmt, &numFormat);
|
wglChoosePixelFormatARB(hDC, wgl_config.pixel_format_attributes.data(), nullptr, 1, &pxfmt, &numFormat);
|
||||||
SetPixelFormat(hDC, pxfmt, &pfd);
|
SetPixelFormat(hDC, pxfmt, &pfd);
|
||||||
hRC = wglCreateContextAttribsARB(hDC, NULL, contex_attribs);
|
hRC = wglCreateContextAttribsARB(hDC, NULL, wgl_config.context_attributes.data());
|
||||||
wglMakeCurrent(hDC, hRC);
|
wglMakeCurrent(hDC, hRC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -114,6 +114,21 @@ constexpr std::uint32_t gl_stream_read = 0x88E1U;
|
|||||||
constexpr std::uint32_t gl_map_read_bit = 0x0001U;
|
constexpr std::uint32_t gl_map_read_bit = 0x0001U;
|
||||||
constexpr std::uint8_t gl_boolean_false = 0U;
|
constexpr std::uint8_t gl_boolean_false = 0U;
|
||||||
constexpr std::uint8_t gl_boolean_true = 1U;
|
constexpr std::uint8_t gl_boolean_true = 1U;
|
||||||
|
constexpr std::int32_t wgl_draw_to_window_arb = 0x2001;
|
||||||
|
constexpr std::int32_t wgl_acceleration_arb = 0x2003;
|
||||||
|
constexpr std::int32_t wgl_support_opengl_arb = 0x2010;
|
||||||
|
constexpr std::int32_t wgl_double_buffer_arb = 0x2011;
|
||||||
|
constexpr std::int32_t wgl_pixel_type_arb = 0x2013;
|
||||||
|
constexpr std::int32_t wgl_color_bits_arb = 0x2014;
|
||||||
|
constexpr std::int32_t wgl_depth_bits_arb = 0x2022;
|
||||||
|
constexpr std::int32_t wgl_full_acceleration_arb = 0x2027;
|
||||||
|
constexpr std::int32_t wgl_type_rgba_arb = 0x202B;
|
||||||
|
constexpr std::int32_t wgl_context_major_version_arb = 0x2091;
|
||||||
|
constexpr std::int32_t wgl_context_minor_version_arb = 0x2092;
|
||||||
|
constexpr std::int32_t wgl_context_flags_arb = 0x2094;
|
||||||
|
constexpr std::int32_t wgl_context_forward_compatible_bit_arb = 0x0002;
|
||||||
|
constexpr std::int32_t wgl_context_profile_mask_arb = 0x9126;
|
||||||
|
constexpr std::int32_t wgl_context_core_profile_bit_arb = 0x00000001;
|
||||||
|
|
||||||
[[nodiscard]] bool contains(std::string_view text, std::string_view needle) noexcept
|
[[nodiscard]] bool contains(std::string_view text, std::string_view needle) noexcept
|
||||||
{
|
{
|
||||||
@@ -741,4 +756,27 @@ std::uint32_t sampler_border_color_parameter_name() noexcept
|
|||||||
return gl_texture_border_color;
|
return gl_texture_border_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenGlWindowsWglContextConfig windows_wgl_core_context_3_3_config() noexcept
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
.context_attributes = {
|
||||||
|
wgl_context_major_version_arb, 3,
|
||||||
|
wgl_context_minor_version_arb, 3,
|
||||||
|
wgl_context_flags_arb, wgl_context_forward_compatible_bit_arb,
|
||||||
|
wgl_context_profile_mask_arb, wgl_context_core_profile_bit_arb,
|
||||||
|
0,
|
||||||
|
},
|
||||||
|
.pixel_format_attributes = {
|
||||||
|
wgl_draw_to_window_arb, static_cast<std::int32_t>(gl_boolean_true),
|
||||||
|
wgl_support_opengl_arb, static_cast<std::int32_t>(gl_boolean_true),
|
||||||
|
wgl_double_buffer_arb, static_cast<std::int32_t>(gl_boolean_true),
|
||||||
|
wgl_acceleration_arb, wgl_full_acceleration_arb,
|
||||||
|
wgl_pixel_type_arb, wgl_type_rgba_arb,
|
||||||
|
wgl_color_bits_arb, 24,
|
||||||
|
wgl_depth_bits_arb, 16,
|
||||||
|
0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ struct OpenGlReadbackFormat {
|
|||||||
std::uint32_t bytes_per_pixel = 0;
|
std::uint32_t bytes_per_pixel = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct OpenGlWindowsWglContextConfig {
|
||||||
|
std::array<std::int32_t, 9> context_attributes {};
|
||||||
|
std::array<std::int32_t, 15> pixel_format_attributes {};
|
||||||
|
};
|
||||||
|
|
||||||
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
|
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
|
||||||
std::span<const std::string_view> extensions,
|
std::span<const std::string_view> extensions,
|
||||||
OpenGlRuntime runtime) noexcept;
|
OpenGlRuntime runtime) noexcept;
|
||||||
@@ -141,5 +146,6 @@ struct OpenGlReadbackFormat {
|
|||||||
std::uint32_t filter_min,
|
std::uint32_t filter_min,
|
||||||
std::uint32_t filter_mag) noexcept;
|
std::uint32_t filter_mag) noexcept;
|
||||||
[[nodiscard]] std::uint32_t sampler_border_color_parameter_name() noexcept;
|
[[nodiscard]] std::uint32_t sampler_border_color_parameter_name() noexcept;
|
||||||
|
[[nodiscard]] OpenGlWindowsWglContextConfig windows_wgl_core_context_3_3_config() noexcept;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -364,6 +364,39 @@ void maps_app_initialization_parameters(pp::tests::Harness& h)
|
|||||||
PP_EXPECT(h, pp::renderer::gl::active_texture_unit(4U) == 0x84C4U);
|
PP_EXPECT(h, pp::renderer::gl::active_texture_unit(4U) == 0x84C4U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void maps_windows_wgl_core_context_parameters(pp::tests::Harness& h)
|
||||||
|
{
|
||||||
|
const auto config = pp::renderer::gl::windows_wgl_core_context_3_3_config();
|
||||||
|
|
||||||
|
PP_EXPECT(h, config.context_attributes.size() == 9U);
|
||||||
|
PP_EXPECT(h, config.context_attributes[0] == 0x2091);
|
||||||
|
PP_EXPECT(h, config.context_attributes[1] == 3);
|
||||||
|
PP_EXPECT(h, config.context_attributes[2] == 0x2092);
|
||||||
|
PP_EXPECT(h, config.context_attributes[3] == 3);
|
||||||
|
PP_EXPECT(h, config.context_attributes[4] == 0x2094);
|
||||||
|
PP_EXPECT(h, config.context_attributes[5] == 0x0002);
|
||||||
|
PP_EXPECT(h, config.context_attributes[6] == 0x9126);
|
||||||
|
PP_EXPECT(h, config.context_attributes[7] == 0x00000001);
|
||||||
|
PP_EXPECT(h, config.context_attributes[8] == 0);
|
||||||
|
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes.size() == 15U);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[0] == 0x2001);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[1] == 1);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[2] == 0x2010);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[3] == 1);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[4] == 0x2011);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[5] == 1);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[6] == 0x2003);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[7] == 0x2027);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[8] == 0x2013);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[9] == 0x202B);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[10] == 0x2014);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[11] == 24);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[12] == 0x2022);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[13] == 16);
|
||||||
|
PP_EXPECT(h, config.pixel_format_attributes[14] == 0);
|
||||||
|
}
|
||||||
|
|
||||||
void rejects_invalid_shader_attribute_binding_catalogs(pp::tests::Harness& h)
|
void rejects_invalid_shader_attribute_binding_catalogs(pp::tests::Harness& h)
|
||||||
{
|
{
|
||||||
const std::array<pp::renderer::gl::OpenGlAttributeBinding, 0> empty {};
|
const std::array<pp::renderer::gl::OpenGlAttributeBinding, 0> empty {};
|
||||||
@@ -457,6 +490,7 @@ int main()
|
|||||||
harness.run("maps_sampler_parameters", maps_sampler_parameters);
|
harness.run("maps_sampler_parameters", maps_sampler_parameters);
|
||||||
harness.run("exposes_shader_attribute_binding_catalog", exposes_shader_attribute_binding_catalog);
|
harness.run("exposes_shader_attribute_binding_catalog", exposes_shader_attribute_binding_catalog);
|
||||||
harness.run("maps_app_initialization_parameters", maps_app_initialization_parameters);
|
harness.run("maps_app_initialization_parameters", maps_app_initialization_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);
|
||||||
harness.run("rejects_invalid_shader_uniform_catalogs", rejects_invalid_shader_uniform_catalogs);
|
harness.run("rejects_invalid_shader_uniform_catalogs", rejects_invalid_shader_uniform_catalogs);
|
||||||
|
|||||||
Reference in New Issue
Block a user