renderer/OpenGL: use compressed texture formats for images

BPTC is required to be available OpenGL >= 4.2 and our minimum is 4.3 so
this is safe in terms of support. I tested briefly in a VM and didn't
encounter any problems so this should just be a complete win.

(Note: texture data is already automatically compressed on Metal)
This commit is contained in:
Qwerasd
2025-06-25 10:53:42 -06:00
committed by Mitchell Hashimoto
parent da46a47726
commit 5cb175ff63
3 changed files with 5 additions and 4 deletions

View File

@ -74,6 +74,9 @@ pub const InternalFormat = enum(c_int) {
srgb = c.GL_SRGB8, srgb = c.GL_SRGB8,
srgba = c.GL_SRGB8_ALPHA8, srgba = c.GL_SRGB8_ALPHA8,
rgba_compressed = c.GL_COMPRESSED_RGBA_BPTC_UNORM,
srgba_compressed = c.GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM,
// There are so many more that I haven't filled in. // There are so many more that I haven't filled in.
_, _,
}; };
@ -126,7 +129,6 @@ pub const Binding = struct {
internal_format: InternalFormat, internal_format: InternalFormat,
width: c.GLsizei, width: c.GLsizei,
height: c.GLsizei, height: c.GLsizei,
border: c.GLint,
format: Format, format: Format,
typ: DataType, typ: DataType,
data: ?*const anyopaque, data: ?*const anyopaque,
@ -137,7 +139,7 @@ pub const Binding = struct {
@intFromEnum(internal_format), @intFromEnum(internal_format),
width, width,
height, height,
border, 0,
@intFromEnum(format), @intFromEnum(format),
@intFromEnum(typ), @intFromEnum(typ),
data, data,

View File

@ -395,7 +395,7 @@ pub inline fn textureOptions(self: OpenGL) Texture.Options {
_ = self; _ = self;
return .{ return .{
.format = .rgba, .format = .rgba,
.internal_format = .srgba, .internal_format = .srgba_compressed,
.target = .@"2D", .target = .@"2D",
}; };
} }

View File

@ -57,7 +57,6 @@ pub fn init(
opts.internal_format, opts.internal_format,
@intCast(width), @intCast(width),
@intCast(height), @intCast(height),
0,
opts.format, opts.format,
.UnsignedByte, .UnsignedByte,
if (data) |d| @ptrCast(d.ptr) else null, if (data) |d| @ptrCast(d.ptr) else null,