Merge branch 'release/1.10.x'

This commit is contained in:
rdb 2022-04-21 11:09:28 +02:00
commit 1b21e604f0
12 changed files with 142 additions and 26 deletions

View File

@ -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()

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,
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;
}

View File

@ -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,
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;
}

View File

@ -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,

View File

@ -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);

View File

@ -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)

View File

@ -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) {

View File

@ -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) {