Merge branch 'release/1.10.x'

This commit is contained in:
rdb 2021-06-01 11:50:12 +02:00
commit 199b797d72
5 changed files with 104 additions and 99 deletions

View File

@ -1170,7 +1170,7 @@ find_display_modes(int width, int height) {
// Get the current refresh rate and pixel encoding.
CFStringRef current_pixel_encoding;
int refresh_rate;
double refresh_rate;
mode = CGDisplayCopyDisplayMode(_display);
// First check if the current mode is adequate.
@ -1204,7 +1204,7 @@ find_display_modes(int width, int height) {
// the mode width and height but also actual pixel widh and height.
if (CGDisplayModeGetWidth(mode) == width &&
CGDisplayModeGetHeight(mode) == height &&
CGDisplayModeGetRefreshRate(mode) == refresh_rate &&
(int)(CGDisplayModeGetRefreshRate(mode) + 0.5) == (int)(refresh_rate + 0.5) &&
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
(floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_14 ||
(CGDisplayModeGetPixelWidth(mode) == expected_pixel_width &&
@ -1212,8 +1212,13 @@ find_display_modes(int width, int height) {
#endif
CFStringCompare(pixel_encoding, current_pixel_encoding, 0) == kCFCompareEqualTo) {
if (CGDisplayModeGetRefreshRate(mode) == refresh_rate) {
// Exact match for refresh rate, prioritize this.
CFArrayInsertValueAtIndex(valid_modes, 0, mode);
} else {
CFArrayAppendValue(valid_modes, mode);
}
}
CFRelease(pixel_encoding);
}

View File

@ -13074,15 +13074,14 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
image = tex->get_uncompressed_ram_image();
}
Texture::TextureType texture_type = tex->get_texture_type();
Texture::CompressionMode image_compression;
if (image.is_null()) {
image_compression = Texture::CM_off;
} else {
image_compression = tex->get_ram_image_compression();
}
bool is_buffer_texture = tex->get_texture_type() == Texture::TT_buffer_texture;
if (is_buffer_texture ||
if (texture_type == Texture::TT_buffer_texture ||
!get_supports_compressed_texture_format(image_compression)) {
image = tex->get_uncompressed_ram_image();
image_compression = Texture::CM_off;
@ -13091,6 +13090,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
// libsquish support or precompress the texture.
nassertr(!image.is_null(), false);
}
}
int mipmap_bias = 0;
@ -13101,7 +13101,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
// If we'll use immutable texture storage, we have to pick a sized image
// format.
bool force_sized = (gl_immutable_texture_storage && _supports_tex_storage) ||
(is_buffer_texture);
(texture_type == Texture::TT_buffer_texture);
GLint internal_format = get_internal_image_format(tex, force_sized);
GLint external_format = get_external_image_format(tex);
@ -13130,7 +13130,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
int max_dimension_y;
int max_dimension_z;
switch (tex->get_texture_type()) {
switch (texture_type) {
case Texture::TT_3d_texture:
max_dimension_x = _max_3d_texture_dimension;
max_dimension_y = _max_3d_texture_dimension;
@ -13235,7 +13235,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
GLenum target = get_texture_target(tex->get_texture_type());
GLenum target = get_texture_target(texture_type);
uses_mipmaps = (uses_mipmaps && !gl_ignore_mipmaps) || gl_force_mipmaps;
#ifndef OPENGLES
if (target == GL_TEXTURE_BUFFER) {
@ -13411,7 +13411,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
<< ", uses_mipmaps = " << uses_mipmaps << "\n";
}
switch (tex->get_texture_type()) {
switch (texture_type) {
case Texture::TT_buffer_texture:
// Won't get here, but squelch compiler warning
case Texture::TT_1d_texture:
@ -13459,7 +13459,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
}
bool success = true;
if (tex->get_texture_type() == Texture::TT_cube_map) {
if (texture_type == Texture::TT_cube_map) {
// A cube map must load six different 2-d images (which are stored as the
// six pages of the system ram image).
if (!_supports_cube_map) {

View File

@ -5,30 +5,6 @@ from panda3d import core
import pytest
def test_round():
original_vector = Vec2(2.3, -2.6)
rounded_vector = round(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
def test_floor():
original_vector = Vec2(2.3, -2.6)
rounded_vector = floor(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
def test_ceil():
original_vector = Vec2(2.3, -2.6)
rounded_vector = ceil(original_vector)
assert rounded_vector.x == 3
assert rounded_vector.y == -2
def test_vec2_creation():
assert Vec2(x=1, y=2) == Vec2(1, 2) == Vec2((1, 2))
@ -120,8 +96,32 @@ def test_vec2_nan():
assert not Vec2D(-inf, 0).is_nan()
def test_vec2_round():
original_vector = Vec2(2.3, -2.6)
rounded_vector = round(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
def test_vec2_floor():
original_vector = Vec2(2.3, -2.6)
rounded_vector = floor(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
def test_vec2_ceil():
original_vector = Vec2(2.3, -2.6)
rounded_vector = ceil(original_vector)
assert rounded_vector.x == 3
assert rounded_vector.y == -2
@pytest.mark.parametrize("type", (core.LVecBase2f, core.LVecBase2d, core.LVecBase2i))
def test_vec4_floordiv(type):
def test_vec2_floordiv(type):
with pytest.raises(ZeroDivisionError):
type(1, 2) // 0

View File

@ -5,33 +5,6 @@ from panda3d import core
import pytest
def test_round():
original_vector = Vec3(2.3, -2.6, 3.5)
rounded_vector = round(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 4
def test_floor():
original_vector = Vec3(2.3, -2.6, 3.5)
rounded_vector = floor(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 3
def test_ceil():
original_vector = Vec3(2.3, -2.6, 3.5)
rounded_vector = ceil(original_vector)
assert rounded_vector.x == 3
assert rounded_vector.y == -2
assert rounded_vector.z == 4
def test_vec3_creation():
assert Vec3(x=1, y=2, z=1) == Vec3(1, 2, 1) == Vec3((1, 2, 1))
@ -105,6 +78,33 @@ def test_vec3_compare():
assert Vec3(0, 0, 1).compare_to(Vec3(0, 0, 1)) == 0
def test_vec3_round():
original_vector = Vec3(2.3, -2.6, 3.5)
rounded_vector = round(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 4
def test_vec3_floor():
original_vector = Vec3(2.3, -2.6, 3.5)
rounded_vector = floor(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 3
def test_vec3_ceil():
original_vector = Vec3(2.3, -2.6, 3.5)
rounded_vector = ceil(original_vector)
assert rounded_vector.x == 3
assert rounded_vector.y == -2
assert rounded_vector.z == 4
@pytest.mark.parametrize("type", (core.LVecBase3f, core.LVecBase3d, core.LVecBase3i))
def test_vec3_floordiv(type):
with pytest.raises(ZeroDivisionError):

View File

@ -5,36 +5,6 @@ from panda3d import core
import pytest
def test_round():
original_vector = Vec4(2.3, -2.6, 3.5, 1)
rounded_vector = round(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 4
assert rounded_vector.w == 1
def test_floor():
original_vector = Vec4(2.3, -2.6, 3.5, 1)
rounded_vector = floor(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 3
assert rounded_vector.w == 1
def test_ceil():
original_vector = Vec4(2.3, -2.6, 3.5, 1)
rounded_vector = ceil(original_vector)
assert rounded_vector.x == 3
assert rounded_vector.y == -2
assert rounded_vector.z == 4
assert rounded_vector.w == 1
def test_vec4_creation():
assert Vec4(x=1, y=2, z=1, w=7) == Vec4(1, 2, 1, 7) == Vec4((1, 2, 1, 7))
@ -121,6 +91,36 @@ def test_vec4_compare():
assert Vec4(0, 0, 0, 1).compare_to(Vec4(0, 0, 0, 1)) == 0
def test_vec4_round():
original_vector = Vec4(2.3, -2.6, 3.5, 1)
rounded_vector = round(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 4
assert rounded_vector.w == 1
def test_vec4_floor():
original_vector = Vec4(2.3, -2.6, 3.5, 1)
rounded_vector = floor(original_vector)
assert rounded_vector.x == 2
assert rounded_vector.y == -3
assert rounded_vector.z == 3
assert rounded_vector.w == 1
def test_vec4_ceil():
original_vector = Vec4(2.3, -2.6, 3.5, 1)
rounded_vector = ceil(original_vector)
assert rounded_vector.x == 3
assert rounded_vector.y == -2
assert rounded_vector.z == 4
assert rounded_vector.w == 1
@pytest.mark.parametrize("type", (core.LVecBase4f, core.LVecBase4d, core.LVecBase4i))
def test_vec4_floordiv(type):
with pytest.raises(ZeroDivisionError):