diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index 432375c6c1..1d60a7a8b2 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -116,7 +116,7 @@ from _frozen_importlib import _imp, FrozenImporter sys.frozen = True -if sys.platform == 'win32': +if sys.platform == 'win32' and sys.version_info < (3, 10): # Make sure the preferred encoding is something we actually support. import _bootlocale enc = _bootlocale.getpreferredencoding().lower() diff --git a/direct/src/filter/CommonFilters.py b/direct/src/filter/CommonFilters.py index 6634b504f2..9242290929 100644 --- a/direct/src/filter/CommonFilters.py +++ b/direct/src/filter/CommonFilters.py @@ -20,6 +20,7 @@ from panda3d.core import LVecBase4, LPoint2 from panda3d.core import AuxBitplaneAttrib from panda3d.core import Texture, Shader, ATSNone from panda3d.core import FrameBufferProperties +from panda3d.core import getDefaultCoordinateSystem, CS_zup_right, CS_zup_left from direct.task.TaskManagerGlobal import taskMgr @@ -52,6 +53,7 @@ o_color = lerp(o_color, k_cartooncolor, cartoon_thresh); SSAO_BODY = """//Cg void vshader(float4 vtx_position : POSITION, + float2 vtx_texcoord : TEXCOORD0, out float4 l_position : POSITION, out float2 l_texcoord : TEXCOORD0, out float2 l_texcoordD : TEXCOORD1, @@ -61,9 +63,9 @@ void vshader(float4 vtx_position : POSITION, uniform float4x4 mat_modelproj) { l_position = mul(mat_modelproj, vtx_position); - l_texcoord = vtx_position.xz; - l_texcoordD = (vtx_position.xz * texpad_depth.xy) + texpad_depth.xy; - l_texcoordN = (vtx_position.xz * texpad_normal.xy) + texpad_normal.xy; + l_texcoord = vtx_texcoord; + l_texcoordD = vtx_texcoord * texpad_depth.xy * 2; + l_texcoordN = vtx_texcoord * texpad_normal.xy * 2; } float3 sphere[16] = float3[](float3(0.53812504, 0.18565957, -0.43192),float3(0.13790712, 0.24864247, 0.44301823),float3(0.33715037, 0.56794053, -0.005789503),float3(-0.6999805, -0.04511441, -0.0019965635),float3(0.06896307, -0.15983082, -0.85477847),float3(0.056099437, 0.006954967, -0.1843352),float3(-0.014653638, 0.14027752, 0.0762037),float3(0.010019933, -0.1924225, -0.034443386),float3(-0.35775623, -0.5301969, -0.43581226),float3(-0.3169221, 0.106360726, 0.015860917),float3(0.010350345, -0.58698344, 0.0046293875),float3(-0.08972908, -0.49408212, 0.3287904),float3(0.7119986, -0.0154690035, -0.09183723),float3(-0.053382345, 0.059675813, -0.5411899),float3(0.035267662, -0.063188605, 0.54602677),float3(-0.47761092, 0.2847911, -0.0271716)); @@ -292,11 +294,19 @@ class CommonFilters: text += "{\n" text += " l_position = mul(mat_modelproj, vtx_position);\n" + # The card is oriented differently depending on our chosen + # coordinate system. We could just use vtx_texcoord, but this + # saves on an additional variable. + if getDefaultCoordinateSystem() in (CS_zup_right, CS_zup_left): + pos = "vtx_position.xz" + else: + pos = "vtx_position.xy" + for texcoord, padTex in texcoordPadding.items(): if padTex is None: - text += " %s = vtx_position.xz * float2(0.5, 0.5) + float2(0.5, 0.5);\n" % (texcoord) + text += " %s = %s * float2(0.5, 0.5) + float2(0.5, 0.5);\n" % (texcoord, pos) else: - text += " %s = (vtx_position.xz * texpad_tx%s.xy) + texpad_tx%s.xy;\n" % (texcoord, padTex, padTex) + text += " %s = (%s * texpad_tx%s.xy) + texpad_tx%s.xy;\n" % (texcoord, pos, padTex, padTex) if "HalfPixelShift" in configuration: text += " %s += texpix_tx%s.xy * 0.5;\n" % (texcoord, padTex) diff --git a/direct/src/filter/filterBloomI.py b/direct/src/filter/filterBloomI.py index 6c44fb3ecb..ddb44c4ad0 100644 --- a/direct/src/filter/filterBloomI.py +++ b/direct/src/filter/filterBloomI.py @@ -32,6 +32,7 @@ BLOOM_I = """ void vshader(float4 vtx_position : POSITION, + float2 vtx_texcoord : TEXCOORD0, out float4 l_position : POSITION, out float2 l_texcoordNW : TEXCOORD0, out float2 l_texcoordNE : TEXCOORD1, @@ -42,7 +43,7 @@ void vshader(float4 vtx_position : POSITION, uniform float4x4 mat_modelproj) { l_position=mul(mat_modelproj, vtx_position); - float2 c=(vtx_position.xz * texpad_src.xy) + texpad_src.xy; + float2 c = vtx_texcoord * texpad_src.xy * 2; float4 offs = texpix_src * 0.5; l_texcoordNW = c + float2( offs.x, -offs.y); l_texcoordNE = c + float2( offs.x, offs.y); diff --git a/direct/src/filter/filterBloomX.py b/direct/src/filter/filterBloomX.py index 220cd776b7..c7e40ab326 100644 --- a/direct/src/filter/filterBloomX.py +++ b/direct/src/filter/filterBloomX.py @@ -2,6 +2,7 @@ BLOOM_X = """ //Cg void vshader(float4 vtx_position : POSITION, + float2 vtx_texcoord : TEXCOORD0, out float4 l_position : POSITION, out float4 l_texcoord0 : TEXCOORD0, out float4 l_texcoord1 : TEXCOORD1, @@ -10,8 +11,8 @@ void vshader(float4 vtx_position : POSITION, uniform float4 texpix_src, uniform float4x4 mat_modelproj) { - l_position=mul(mat_modelproj, vtx_position); - float2 c=(vtx_position.xz * texpad_src.xy) + texpad_src.xy; + l_position = mul(mat_modelproj, vtx_position); + float2 c = vtx_texcoord * texpad_src.xy * 2; float offset = texpix_src.x; float pad = texpad_src.x * 2; l_texcoord0 = float4(min(c.x-offset* -4, pad), min(c.x-offset* -3, pad), min(c.x-offset* -2, pad), c.y); diff --git a/direct/src/filter/filterBloomY.py b/direct/src/filter/filterBloomY.py index 18e2885b1e..0b6cc9d5f8 100644 --- a/direct/src/filter/filterBloomY.py +++ b/direct/src/filter/filterBloomY.py @@ -2,6 +2,7 @@ BLOOM_Y = """ //Cg void vshader(float4 vtx_position : POSITION, + float2 vtx_texcoord : TEXCOORD0, out float4 l_position : POSITION, out float4 l_texcoord0 : TEXCOORD0, out float4 l_texcoord1 : TEXCOORD1, @@ -11,7 +12,7 @@ void vshader(float4 vtx_position : POSITION, uniform float4x4 mat_modelproj) { l_position=mul(mat_modelproj, vtx_position); - float2 c=(vtx_position.xz * texpad_src.xy) + texpad_src.xy; + float2 c = vtx_texcoord * texpad_src.xy * 2; float offset = texpix_src.y; float pad = texpad_src.y * 2; l_texcoord0 = float4(min(c.y-offset* -4, pad), min(c.y-offset* -3, pad), min(c.y-offset* -2, pad), c.x); diff --git a/direct/src/filter/filterBlurX.py b/direct/src/filter/filterBlurX.py index b472a5d7a7..426c1dc9a7 100644 --- a/direct/src/filter/filterBlurX.py +++ b/direct/src/filter/filterBlurX.py @@ -4,14 +4,14 @@ BLUR_X = """ //Cg profile arbvp1 arbfp1 void vshader(float4 vtx_position : POSITION, - float2 vtx_texcoord0 : TEXCOORD0, + float2 vtx_texcoord : TEXCOORD0, out float4 l_position : POSITION, - out float2 l_texcoord0 : TEXCOORD0, + out float2 l_texcoord0 : TEXCOORD0, uniform float4 texpad_src, uniform float4x4 mat_modelproj) { - l_position=mul(mat_modelproj, vtx_position); - l_texcoord0 = (vtx_position.xz * texpad_src.xy) + texpad_src.xy; + l_position = mul(mat_modelproj, vtx_position); + l_texcoord0 = vtx_texcoord * texpad_src.xy * 2; } diff --git a/direct/src/filter/filterBlurY.py b/direct/src/filter/filterBlurY.py index 173c7a73b5..00d0980b30 100644 --- a/direct/src/filter/filterBlurY.py +++ b/direct/src/filter/filterBlurY.py @@ -4,14 +4,14 @@ BLUR_Y = """ //Cg profile arbvp1 arbfp1 void vshader(float4 vtx_position : POSITION, - float2 vtx_texcoord0 : TEXCOORD0, + float2 vtx_texcoord : TEXCOORD0, out float4 l_position : POSITION, - out float2 l_texcoord0 : TEXCOORD0, + out float2 l_texcoord0 : TEXCOORD0, uniform float4 texpad_src, uniform float4x4 mat_modelproj) { - l_position=mul(mat_modelproj, vtx_position); - l_texcoord0 = (vtx_position.xz * texpad_src.xy) + texpad_src.xy; + l_position = mul(mat_modelproj, vtx_position); + l_texcoord0 = vtx_texcoord * texpad_src.xy * 2; } diff --git a/direct/src/filter/filterCopy.py b/direct/src/filter/filterCopy.py index d9770fb04b..dee3dadace 100644 --- a/direct/src/filter/filterCopy.py +++ b/direct/src/filter/filterCopy.py @@ -3,13 +3,14 @@ COPY = """ void vshader(float4 vtx_position : POSITION, + float2 vtx_texcoord : TEXCOORD0, out float4 l_position : POSITION, out float2 l_texcoord : TEXCOORD0, uniform float4 texpad_src, uniform float4x4 mat_modelproj) { - l_position=mul(mat_modelproj, vtx_position); - l_texcoord = (vtx_position.xz * texpad_src.xy) + texpad_src.xy; + l_position = mul(mat_modelproj, vtx_position); + l_texcoord = vtx_texcoord * texpad_src.xy * 2; } void fshader(float2 l_texcoord : TEXCOORD0, diff --git a/direct/src/filter/filterDown4.py b/direct/src/filter/filterDown4.py index 14595dbbd7..d0c7ab4d2c 100644 --- a/direct/src/filter/filterDown4.py +++ b/direct/src/filter/filterDown4.py @@ -2,6 +2,7 @@ DOWN_4 = """ //Cg void vshader(float4 vtx_position : POSITION, + float2 vtx_texcoord : TEXCOORD0, out float4 l_position : POSITION, out float2 l_texcoordNW : TEXCOORD0, out float2 l_texcoordNE : TEXCOORD1, @@ -11,8 +12,8 @@ void vshader(float4 vtx_position : POSITION, uniform float4 texpix_src, uniform float4x4 mat_modelproj) { - l_position=mul(mat_modelproj, vtx_position); - float2 c=(vtx_position.xz * texpad_src.xy) + texpad_src.xy; + l_position = mul(mat_modelproj, vtx_position); + float2 c = vtx_texcoord * texpad_src.xy * 2; l_texcoordNW = c + float2( texpix_src.x, -texpix_src.y); l_texcoordNE = c + float2( texpix_src.x, texpix_src.y); l_texcoordSW = c + float2(-texpix_src.x, -texpix_src.y); diff --git a/direct/src/showbase/BufferViewer.py b/direct/src/showbase/BufferViewer.py index 8c6c2c72e9..8c1ec73712 100644 --- a/direct/src/showbase/BufferViewer.py +++ b/direct/src/showbase/BufferViewer.py @@ -240,10 +240,10 @@ class BufferViewer(DirectObject): offsetx = (ringoffset[ring]*2.0) / float(sizex) offsety = (ringoffset[ring]*2.0) / float(sizey) bright = ringbright[ring] - vwriter.addData3f(-1-offsetx, 0, -1-offsety) - vwriter.addData3f(1+offsetx, 0, -1-offsety) - vwriter.addData3f(1+offsetx, 0, 1+offsety) - vwriter.addData3f(-1-offsetx, 0, 1+offsety) + vwriter.addData3f(Vec3.rfu(-1 - offsetx, 0, -1 - offsety)) + vwriter.addData3f(Vec3.rfu( 1 + offsetx, 0, -1 - offsety)) + vwriter.addData3f(Vec3.rfu( 1 + offsetx, 0, 1 + offsety)) + vwriter.addData3f(Vec3.rfu(-1 - offsetx, 0, 1 + offsety)) cwriter.addData3f(bright, bright, bright) cwriter.addData3f(bright, bright, bright) cwriter.addData3f(bright, bright, bright) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index d6dc3c678d..8053b13a9a 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -1409,6 +1409,10 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, GraphicsOutput *win = wlist[wi]; if (win->is_active() && win->get_gsg()->is_active()) { if (win->flip_ready()) { + if (display_cat.is_spam()) { + display_cat.spam() + << "Flipping window " << win->get_name() << "\n"; + } PStatTimer timer(_flip_pcollector, current_thread); win->begin_flip(); win->end_flip(); @@ -1423,6 +1427,11 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, gsg->pop_group_marker(); } + if (display_cat.is_spam()) { + display_cat.spam() + << "Culling and drawing window " << win->get_name() << "\n"; + } + int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { PT(DisplayRegion) dr = win->get_active_display_region(i); @@ -1434,6 +1443,10 @@ cull_and_draw_together(GraphicsEngine::Windows wlist, if (_auto_flip) { if (win->flip_ready()) { + if (display_cat.is_spam()) { + display_cat.spam() + << "Flipping window " << win->get_name() << "\n"; + } PStatTimer timer(_flip_pcollector, current_thread); win->begin_flip(); win->end_flip(); @@ -1530,6 +1543,11 @@ cull_to_bins(GraphicsEngine::Windows wlist, Thread *current_thread) { for (size_t wi = 0; wi < wlist_size; ++wi) { GraphicsOutput *win = wlist[wi]; if (win->is_active() && win->get_gsg()->is_active()) { + if (display_cat.is_spam()) { + display_cat.spam() + << "Culling window " << win->get_name() << "\n"; + } + GraphicsStateGuardian *gsg = win->get_gsg(); PStatTimer timer(win->get_cull_window_pcollector(), current_thread); int num_display_regions = win->get_num_active_display_regions(); @@ -1687,6 +1705,10 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { GraphicsOutput *host = win->get_host(); if (host->flip_ready()) { + if (display_cat.is_spam()) { + display_cat.spam() + << "Flipping window " << win->get_name() << "\n"; + } PStatTimer timer(_flip_pcollector, current_thread); host->begin_flip(); host->end_flip(); @@ -1720,6 +1742,10 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { if (_auto_flip) { if (win->flip_ready()) { + if (display_cat.is_spam()) { + display_cat.spam() + << "Flipping window " << win->get_name() << "\n"; + } PStatGPUTimer timer(gsg, _flip_pcollector, current_thread); win->begin_flip(); win->end_flip(); @@ -1790,6 +1816,11 @@ flip_windows(const GraphicsEngine::Windows &wlist, Thread *current_thread) { for (i = 0; i < num_windows; ++i) { GraphicsOutput *win = wlist[i]; if (win->flip_ready()) { + if (display_cat.is_spam()) { + display_cat.spam() + << "Flipping window " << win->get_name() << "\n"; + } + nassertv(warray_count < num_windows); warray[warray_count] = win; ++warray_count; @@ -2217,6 +2248,11 @@ void GraphicsEngine:: do_resort_windows() { _windows_sorted = true; + if (display_cat.is_spam()) { + display_cat.spam() + << "Re-sorting window list.\n"; + } + _app.resort_windows(); Threads::const_iterator ti; for (ti = _threads.begin(); ti != _threads.end(); ++ti) { diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index 4815262a77..28787c43b3 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -247,6 +247,71 @@ WinGraphicsPipe() { } } + if (windisplay_cat.is_debug()) { + windisplay_cat.debug() + << "Detected display devices:\n"; + + DISPLAY_DEVICEA device; + device.cb = sizeof(device); + for (DWORD devnum = 0; EnumDisplayDevicesA(nullptr, devnum, &device, 0); ++devnum) { + std::ostream &out = windisplay_cat.debug(); + out << " " << device.DeviceName << " [" << device.DeviceString << "]"; + if (device.StateFlags & DISPLAY_DEVICE_ACTIVE) { + out << " (active)"; + } + if (device.StateFlags & DISPLAY_DEVICE_MULTI_DRIVER) { + out << " (multi-driver)"; + } + if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { + out << " (primary)"; + } + if (device.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) { + out << " (mirroring)"; + } + if (device.StateFlags & DISPLAY_DEVICE_REMOVABLE) { + out << " (removable)"; + } + out << "\n"; + } + + int nmonitor = GetSystemMetrics(SM_CMONITORS); + windisplay_cat.debug() + << "Detected " << nmonitor << " monitors, " + << (GetSystemMetrics(SM_SAMEDISPLAYFORMAT) != 0 ? "" : "NOT ") + << "sharing same display format:\n"; + + EnumDisplayMonitors( + nullptr, + nullptr, + [](HMONITOR monitor, HDC dc, LPRECT rect, LPARAM param) -> BOOL { + MONITORINFOEXA info; + info.cbSize = sizeof(info); + if (GetMonitorInfoA(monitor, &info)) { + std::ostream &out = windisplay_cat.debug() << " "; + + DISPLAY_DEVICEA device; + device.cb = sizeof(device); + device.StateFlags = 0; + if (EnumDisplayDevicesA(info.szDevice, 0, &device, 0)) { + out << device.DeviceName << " [" << device.DeviceString << "]"; + } + else { + out << info.szDevice << " (device enum failed)"; + } + + if (info.dwFlags & MONITORINFOF_PRIMARY) { + out << " (primary)"; + } + if (info.rcWork.left != 0 || info.rcWork.top != 0) { + out << " (at " << info.rcWork.left << "x" << info.rcWork.top << ")"; + } + out << "\n"; + } + return TRUE; + }, + 0); + } + #ifdef HAVE_DX9 // Use D3D to get display info. This is disabled by default as it is slow. if (request_dxdisplay_information) {