From e0c3c8a8d9ef76dfe7cd0f1aa2c2793d5ef27f45 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 25 Oct 2022 17:50:45 +0200 Subject: [PATCH 1/7] filter: Add docstring for CommonFilters.setMSAA [skip ci] --- direct/src/filter/CommonFilters.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/direct/src/filter/CommonFilters.py b/direct/src/filter/CommonFilters.py index c5313d0662..8c4857f1f9 100644 --- a/direct/src/filter/CommonFilters.py +++ b/direct/src/filter/CommonFilters.py @@ -466,6 +466,13 @@ class CommonFilters: return task.cont def setMSAA(self, samples): + """Enables multisample anti-aliasing on the render-to-texture buffer. + If you enable this, it is recommended to leave any multisample request + on the main framebuffer OFF (ie. don't set framebuffer-multisample true + in Config.prc), since it would be a waste of resources otherwise. + + .. versionadded:: 1.10.13 + """ fullrebuild = "MSAA" not in self.configuration or self.configuration["MSAA"].samples != samples newconfig = FilterConfig() newconfig.samples = samples From a111bb4442b035bab61bf0c418e8ac75372c3699 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 1 Apr 2019 15:39:02 +0200 Subject: [PATCH 2/7] tests: skip auto-shader tests if Cg shaders are not supported Backport of 57b0be86471f4356b912d5976e4f5b9cb9e92220 --- tests/display/test_color_buffer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/display/test_color_buffer.py b/tests/display/test_color_buffer.py index d59b86a0cf..1450981f37 100644 --- a/tests/display/test_color_buffer.py +++ b/tests/display/test_color_buffer.py @@ -115,6 +115,12 @@ def render_color_pixel(region, state, vertex_color=None): """Renders a fragment using the specified render settings, and returns the resulting color value.""" + # Skip auto-shader tests if we don't support Cg shaders. + if not region.window.gsg.supports_basic_shaders: + sattr = state.get_attrib(core.ShaderAttrib) + if sattr and sattr.auto_shader(): + pytest.skip("Cannot test auto-shader without Cg shader support") + # Set up the scene with a blank card rendering at specified distance. scene = core.NodePath("root") scene.set_attrib(core.DepthTestAttrib.make(core.RenderAttrib.M_always)) From 979f194f499e76a12ba137c52b3b33f51d7d8e6c Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Oct 2022 18:34:38 +0200 Subject: [PATCH 3/7] tests: Load either 120 or 150 GLSL shaders depending on capabilities Addresses part of #804 --- tests/display/glsl_bad.vert | 2 +- tests/display/glsl_bad_legacy.vert | 12 ++++++++++ tests/display/glsl_include.vert | 7 ++++-- ...e_inputs.vert => glsl_include_inputs.glsl} | 3 --- tests/display/glsl_include_legacy.vert | 10 ++++++++ tests/display/glsl_simple.frag | 6 +++-- tests/display/glsl_simple.vert | 2 +- tests/display/glsl_simple_legacy.frag | 5 ++++ tests/display/glsl_simple_legacy.vert | 11 +++++++++ tests/display/test_glsl_shader.py | 24 ++++++++++++++----- 10 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 tests/display/glsl_bad_legacy.vert rename tests/display/{glsl_include_inputs.vert => glsl_include_inputs.glsl} (62%) create mode 100644 tests/display/glsl_include_legacy.vert create mode 100644 tests/display/glsl_simple_legacy.frag create mode 100644 tests/display/glsl_simple_legacy.vert diff --git a/tests/display/glsl_bad.vert b/tests/display/glsl_bad.vert index 8a324916ec..e06e2948d1 100644 --- a/tests/display/glsl_bad.vert +++ b/tests/display/glsl_bad.vert @@ -1,4 +1,4 @@ -#version 130 +#version 150 // Uniform inputs uniform mat4 p3d_ModelViewProjectionMatrix; diff --git a/tests/display/glsl_bad_legacy.vert b/tests/display/glsl_bad_legacy.vert new file mode 100644 index 0000000000..e96ecdc39e --- /dev/null +++ b/tests/display/glsl_bad_legacy.vert @@ -0,0 +1,12 @@ +#version 120 + +// Uniform inputs +uniform mat4 p3d_ModelViewProjectionMatrix; + +// Vertex inputs +attribute vec4 p3d_Vertex; + +void main() { + gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex; + does_not_exist = p3d_Vertex; +} diff --git a/tests/display/glsl_include.vert b/tests/display/glsl_include.vert index 1826fdf677..21ba97b8ca 100644 --- a/tests/display/glsl_include.vert +++ b/tests/display/glsl_include.vert @@ -1,6 +1,9 @@ -#version 130 +#version 150 -#pragma include "glsl_include_inputs.vert" +#pragma include "glsl_include_inputs.glsl" + +// Vertex inputs +in vec4 p3d_Vertex; void main() { gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex; diff --git a/tests/display/glsl_include_inputs.vert b/tests/display/glsl_include_inputs.glsl similarity index 62% rename from tests/display/glsl_include_inputs.vert rename to tests/display/glsl_include_inputs.glsl index 125078ce16..58eb09c181 100644 --- a/tests/display/glsl_include_inputs.vert +++ b/tests/display/glsl_include_inputs.glsl @@ -1,5 +1,2 @@ // Uniform inputs uniform mat4 p3d_ModelViewProjectionMatrix; - -// Vertex inputs -in vec4 p3d_Vertex; diff --git a/tests/display/glsl_include_legacy.vert b/tests/display/glsl_include_legacy.vert new file mode 100644 index 0000000000..0111515310 --- /dev/null +++ b/tests/display/glsl_include_legacy.vert @@ -0,0 +1,10 @@ +#version 120 + +#pragma include "glsl_include_inputs.glsl" + +// Vertex inputs +attribute vec4 p3d_Vertex; + +void main() { + gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex; +} diff --git a/tests/display/glsl_simple.frag b/tests/display/glsl_simple.frag index 5f190e015c..66a6143f50 100644 --- a/tests/display/glsl_simple.frag +++ b/tests/display/glsl_simple.frag @@ -1,5 +1,7 @@ -#version 130 +#version 150 + +out vec4 p3d_FragColor; void main() { - gl_FragColor = vec4(0, 0, 0, 1); + p3d_FragColor = vec4(0, 0, 0, 1); } diff --git a/tests/display/glsl_simple.vert b/tests/display/glsl_simple.vert index ea3afd7498..2e3f7db8f8 100644 --- a/tests/display/glsl_simple.vert +++ b/tests/display/glsl_simple.vert @@ -1,4 +1,4 @@ -#version 130 +#version 150 // Uniform inputs uniform mat4 p3d_ModelViewProjectionMatrix; diff --git a/tests/display/glsl_simple_legacy.frag b/tests/display/glsl_simple_legacy.frag new file mode 100644 index 0000000000..c7f34a5da9 --- /dev/null +++ b/tests/display/glsl_simple_legacy.frag @@ -0,0 +1,5 @@ +#version 120 + +void main() { + gl_FragColor = vec4(0, 0, 0, 1); +} diff --git a/tests/display/glsl_simple_legacy.vert b/tests/display/glsl_simple_legacy.vert new file mode 100644 index 0000000000..523362f606 --- /dev/null +++ b/tests/display/glsl_simple_legacy.vert @@ -0,0 +1,11 @@ +#version 120 + +// Uniform inputs +uniform mat4 p3d_ModelViewProjectionMatrix; + +// Vertex inputs +attribute vec4 p3d_Vertex; + +void main() { + gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex; +} diff --git a/tests/display/test_glsl_shader.py b/tests/display/test_glsl_shader.py index 97718ac4b7..4a4314ba9d 100644 --- a/tests/display/test_glsl_shader.py +++ b/tests/display/test_glsl_shader.py @@ -111,6 +111,9 @@ def run_glsl_compile_check(gsg, vert_path, frag_path, expect_fail=False): shader = core.Shader.load(core.Shader.SL_GLSL, vert_path, frag_path) assert shader is not None + if not gsg.supports_glsl: + expect_fail = True + shader.prepare_now(gsg.prepared_objects, gsg) assert shader.is_prepared(gsg.prepared_objects) if expect_fail: @@ -468,20 +471,29 @@ def test_glsl_write_extract_image_buffer(gsg): def test_glsl_compile_error(gsg): """Test getting compile errors from bad shaders""" - vert_path = core.Filename(SHADERS_DIR, 'glsl_bad.vert') - frag_path = core.Filename(SHADERS_DIR, 'glsl_simple.frag') + suffix = '' + if (gsg.driver_shader_version_major, gsg.driver_shader_version_minor) < (1, 50): + suffix = '_legacy' + vert_path = core.Filename(SHADERS_DIR, 'glsl_bad' + suffix + '.vert') + frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag') run_glsl_compile_check(gsg, vert_path, frag_path, expect_fail=True) def test_glsl_from_file(gsg): """Test compiling GLSL shaders from files""" - vert_path = core.Filename(SHADERS_DIR, 'glsl_simple.vert') - frag_path = core.Filename(SHADERS_DIR, 'glsl_simple.frag') + suffix = '' + if (gsg.driver_shader_version_major, gsg.driver_shader_version_minor) < (1, 50): + suffix = '_legacy' + vert_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.vert') + frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag') run_glsl_compile_check(gsg, vert_path, frag_path) def test_glsl_includes(gsg): """Test preprocessing includes in GLSL shaders""" - vert_path = core.Filename(SHADERS_DIR, 'glsl_include.vert') - frag_path = core.Filename(SHADERS_DIR, 'glsl_simple.frag') + suffix = '' + if (gsg.driver_shader_version_major, gsg.driver_shader_version_minor) < (1, 50): + suffix = '_legacy' + vert_path = core.Filename(SHADERS_DIR, 'glsl_include' + suffix + '.vert') + frag_path = core.Filename(SHADERS_DIR, 'glsl_simple' + suffix + '.frag') run_glsl_compile_check(gsg, vert_path, frag_path) From 4c6df54d6fd17f65696ca5ffd846f62f919937f3 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Oct 2022 18:44:05 +0200 Subject: [PATCH 4/7] tests: Fix failing window unit test on macOS Fixes #804 (together with previous commit 979f194f499e76a12ba137c52b3b33f51d7d8e6c) --- tests/display/test_window.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/display/test_window.py b/tests/display/test_window.py index 1c44ea76e3..ff434b8dfc 100644 --- a/tests/display/test_window.py +++ b/tests/display/test_window.py @@ -11,6 +11,7 @@ def test_window_basic(window): default_props.set_origin(current_props.get_origin()) default_props.set_minimized(False) default_props.foreground = current_props.foreground + default_props.z_order = current_props.z_order # The rest should be the same assert current_props == default_props From 4cf8187df7b02584278dd2e5f615d043295959d6 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Oct 2022 20:51:05 +0200 Subject: [PATCH 5/7] cocoadisplay: Fix crash with threading-model on newer macOS versions Updates the context on the main thread instead of the draw thread now. If render_frame happens to run while the context needs updating, it will skip the frame. Fixes #1286 --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 90699ef26d..ea48bb8c79 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -207,8 +207,13 @@ begin_frame(FrameMode mode, Thread *current_thread) { // Update the context if necessary, to make it reallocate buffers etc. if (_context_needs_update) { - [cocoagsg->_context update]; - _context_needs_update = false; + if ([NSThread isMainThread]) { + [cocoagsg->_context update]; + _context_needs_update = false; + } else { + cocoagsg->unlock_context(); + return false; + } } // Lock the view for drawing. @@ -349,6 +354,18 @@ process_events() { } [pool release]; + + if (_context_needs_update && _gsg != nullptr) { + CocoaGraphicsStateGuardian *cocoagsg; + DCAST_INTO_V(cocoagsg, _gsg); + + if (cocoagsg != nullptr && cocoagsg->_context != nil) { + cocoagsg->lock_context(); + _context_needs_update = false; + [cocoagsg->_context update]; + cocoagsg->unlock_context(); + } + } } /** @@ -1194,6 +1211,18 @@ set_properties_now(WindowProperties &properties) { break; } } + + if (_context_needs_update && _gsg != nullptr) { + CocoaGraphicsStateGuardian *cocoagsg; + DCAST_INTO_V(cocoagsg, _gsg); + + if (cocoagsg != nullptr && cocoagsg->_context != nil) { + cocoagsg->lock_context(); + _context_needs_update = false; + [cocoagsg->_context update]; + cocoagsg->unlock_context(); + } + } } /** From 587f9f7bcdf7c5672d006b841e2d276c6cba27d9 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 31 Oct 2022 19:25:47 +0100 Subject: [PATCH 6/7] makepanda: Fix issues when building on arm64 without `--arch` flag Logic in various places seems to assume `OSX_ARCHS` contains `arm64` in this case --- makepanda/makepanda.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index c7d2c5d309..5034f88dab 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -338,6 +338,9 @@ def parseopts(args): if 'arm64' in target_archs and OSXTARGET and OSXTARGET < (10, 9): exit("Must have at least --osxtarget 10.9 when targeting arm64") + elif platform.machine() == 'arm64': + OSX_ARCHS = ('arm64',) + try: SetOptimize(int(optimize)) assert GetOptimize() in [1, 2, 3, 4] From d8a537b59b909c13e3109b6ddda14e321ce3a2fc Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 31 Oct 2022 19:26:59 +0100 Subject: [PATCH 7/7] dtoolbase: Add comment clarifying assertion in DeletedBufferChain [skip ci] --- dtool/src/dtoolbase/deletedBufferChain.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index d009510ad3..8c6ae42860 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -36,6 +36,7 @@ allocate(size_t size, TypeHandle type_handle) { #ifdef USE_DELETED_CHAIN // TAU_PROFILE("void *DeletedBufferChain::allocate(size_t, TypeHandle)", " // ", TAU_USER); + // If this triggers, maybe you forgot ALLOC_DELETED_CHAIN in a subclass? assert(size <= _buffer_size); // Determine how much space to allocate.