Do not use GL_ARB_texture_buffer_object_rgb32
This is not available on macOS using Intel graphics cards
This commit is contained in:
parent
a9f3a698d2
commit
101a50b0ff
@ -17,7 +17,7 @@ from .fast_data_types import (
|
|||||||
CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE, DATA_CELL_SIZE, GL_BLEND,
|
CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE, DATA_CELL_SIZE, GL_BLEND,
|
||||||
GL_LINE_LOOP, GL_TRIANGLE_FAN, ColorProfile, glDisable, glDrawArrays,
|
GL_LINE_LOOP, GL_TRIANGLE_FAN, ColorProfile, glDisable, glDrawArrays,
|
||||||
glDrawArraysInstanced, glEnable, glUniform1i, glUniform2f, glUniform2ui,
|
glDrawArraysInstanced, glEnable, glUniform1i, glUniform2f, glUniform2ui,
|
||||||
glUniform4f
|
glUniform4f, glUniform2i
|
||||||
)
|
)
|
||||||
from .rgb import to_color
|
from .rgb import to_color
|
||||||
from .utils import (
|
from .utils import (
|
||||||
@ -44,7 +44,7 @@ uniform uvec2 dimensions; // xnum, ynum
|
|||||||
uniform vec4 steps; // xstart, ystart, dx, dy
|
uniform vec4 steps; // xstart, ystart, dx, dy
|
||||||
uniform vec2 sprite_layout; // dx, dy
|
uniform vec2 sprite_layout; // dx, dy
|
||||||
uniform usamplerBuffer sprite_map; // gl_InstanceID -> x, y, z
|
uniform usamplerBuffer sprite_map; // gl_InstanceID -> x, y, z
|
||||||
uniform uvec2 color_indices; // which color to use as fg and which as bg
|
uniform ivec2 color_indices; // which color to use as fg and which as bg
|
||||||
out vec3 sprite_pos;
|
out vec3 sprite_pos;
|
||||||
out vec3 underline_pos;
|
out vec3 underline_pos;
|
||||||
out vec3 strike_pos;
|
out vec3 strike_pos;
|
||||||
@ -89,17 +89,21 @@ void main() {
|
|||||||
gl_Position = vec4(xpos[pos[0]], ypos[pos[1]], 0, 1);
|
gl_Position = vec4(xpos[pos[0]], ypos[pos[1]], 0, 1);
|
||||||
|
|
||||||
int sprite_id = gl_InstanceID * STRIDE;
|
int sprite_id = gl_InstanceID * STRIDE;
|
||||||
uvec4 spos = texelFetch(sprite_map, sprite_id);
|
uint x = texelFetch(sprite_map, sprite_id).r;
|
||||||
uvec4 colors = texelFetch(sprite_map, sprite_id + 1);
|
uint y = texelFetch(sprite_map, sprite_id + 1).r;
|
||||||
sprite_pos = to_sprite_pos(pos, spos[0], spos[1], spos[2]);
|
uint z = texelFetch(sprite_map, sprite_id + 2).r;
|
||||||
foreground = to_color(colors[color_indices[0]]);
|
sprite_pos = to_sprite_pos(pos, x, y, z);
|
||||||
background = to_color(colors[color_indices[1]]);
|
sprite_id += 3;
|
||||||
uint decoration = colors[2];
|
uint fg = texelFetch(sprite_map, sprite_id + color_indices[0]).r;
|
||||||
|
uint bg = texelFetch(sprite_map, sprite_id + color_indices[1]).r;
|
||||||
|
uint decoration = texelFetch(sprite_map, sprite_id + 2).r;
|
||||||
|
foreground = to_color(fg);
|
||||||
|
background = to_color(bg);
|
||||||
decoration_fg = to_color(decoration);
|
decoration_fg = to_color(decoration);
|
||||||
underline_pos = to_sprite_pos(pos, (decoration >> 24) & SMASK, ZERO, ZERO);
|
underline_pos = to_sprite_pos(pos, (decoration >> 24) & SMASK, ZERO, ZERO);
|
||||||
strike_pos = to_sprite_pos(pos, (decoration >> 26) & SMASK, ZERO, ZERO);
|
strike_pos = to_sprite_pos(pos, (decoration >> 26) & SMASK, ZERO, ZERO);
|
||||||
}
|
}
|
||||||
'''.replace('STRIDE', str(DATA_CELL_SIZE // 3)),
|
'''.replace('STRIDE', str(DATA_CELL_SIZE)),
|
||||||
|
|
||||||
'''\
|
'''\
|
||||||
uniform sampler2DArray sprites;
|
uniform sampler2DArray sprites;
|
||||||
@ -234,7 +238,7 @@ def render_cells(buffer_id, sg, cell_program, sprites, invert_colors=False):
|
|||||||
sprites.bind_sprite_map(buffer_id)
|
sprites.bind_sprite_map(buffer_id)
|
||||||
ul = cell_program.uniform_location
|
ul = cell_program.uniform_location
|
||||||
glUniform2ui(ul('dimensions'), sg.xnum, sg.ynum)
|
glUniform2ui(ul('dimensions'), sg.xnum, sg.ynum)
|
||||||
glUniform2ui(ul('color_indices'), 1 if invert_colors else 0, 0 if invert_colors else 1)
|
glUniform2i(ul('color_indices'), 1 if invert_colors else 0, 0 if invert_colors else 1)
|
||||||
glUniform4f(ul('steps'), sg.xstart, sg.ystart, sg.dx, sg.dy)
|
glUniform4f(ul('steps'), sg.xstart, sg.ystart, sg.dx, sg.dy)
|
||||||
glUniform1i(ul('sprites'), sprites.sampler_num)
|
glUniform1i(ul('sprites'), sprites.sampler_num)
|
||||||
glUniform1i(ul('sprite_map'), sprites.buffer_sampler_num)
|
glUniform1i(ul('sprite_map'), sprites.buffer_sampler_num)
|
||||||
|
|||||||
@ -35,8 +35,7 @@ typedef unsigned int index_type;
|
|||||||
|
|
||||||
#define CELL_FIELD_COUNT 5
|
#define CELL_FIELD_COUNT 5
|
||||||
#define CELL_SIZE (CELL_FIELD_COUNT * 4)
|
#define CELL_SIZE (CELL_FIELD_COUNT * 4)
|
||||||
// The data cell size must be a multiple of 3
|
#define DATA_CELL_SIZE 6
|
||||||
#define DATA_CELL_SIZE 2 * 3
|
|
||||||
|
|
||||||
#define CHAR_MASK 0xFFFFFF
|
#define CHAR_MASK 0xFFFFFF
|
||||||
#define ATTRS_SHIFT 24
|
#define ATTRS_SHIFT 24
|
||||||
|
|||||||
20
kitty/gl.h
20
kitty/gl.h
@ -84,6 +84,16 @@ Uniform2ui(PyObject UNUSED *self, PyObject *args) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
Uniform2i(PyObject UNUSED *self, PyObject *args) {
|
||||||
|
int location;
|
||||||
|
int x, y;
|
||||||
|
if (!PyArg_ParseTuple(args, "iii", &location, &x, &y)) return NULL;
|
||||||
|
glUniform2i(location, x, y);
|
||||||
|
CHECK_ERROR;
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
Uniform1i(PyObject UNUSED *self, PyObject *args) {
|
Uniform1i(PyObject UNUSED *self, PyObject *args) {
|
||||||
int location;
|
int location;
|
||||||
@ -147,7 +157,6 @@ _glewInit(PyObject UNUSED *self) {
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
}
|
}
|
||||||
ARB_TEST(texture_storage);
|
ARB_TEST(texture_storage);
|
||||||
ARB_TEST(texture_buffer_object_rgb32);
|
|
||||||
#undef ARB_TEST
|
#undef ARB_TEST
|
||||||
#endif
|
#endif
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
@ -657,19 +666,19 @@ static PyObject*
|
|||||||
check_for_extensions(PyObject UNUSED *self) {
|
check_for_extensions(PyObject UNUSED *self) {
|
||||||
GLint n = 0, i, left = 2;
|
GLint n = 0, i, left = 2;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||||
bool texture_storage = false, texture_buffer_object_rgb32 = false;
|
bool texture_storage = false;
|
||||||
#define CHECK(name) if (!name) { \
|
#define CHECK(name) if (!name) { \
|
||||||
if (strstr((const char*)ext, "GL_ARB_" #name) == (const char *)ext) { left--; name = true; } \
|
if (strstr((const char*)ext, "GL_ARB_" #name) == (const char *)ext) { left--; name = true; } \
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
const GLubyte *ext = glGetStringi(GL_EXTENSIONS, i);
|
const GLubyte *ext = glGetStringi(GL_EXTENSIONS, i);
|
||||||
CHECK(texture_storage); CHECK(texture_buffer_object_rgb32);
|
CHECK(texture_storage);
|
||||||
if (left < 1) break;
|
if (left < 1) break;
|
||||||
}
|
}
|
||||||
#undef CHECK
|
#undef CHECK
|
||||||
if (left > 0) {
|
if (left > 0) {
|
||||||
#define CHECK(name) if (!name) { PyErr_Format(PyExc_RuntimeError, "The OpenGL driver on this system is missing the required extension: GL_ARB_%s", #name); return NULL; }
|
#define CHECK(name) if (!name) { PyErr_Format(PyExc_RuntimeError, "The OpenGL driver on this system is missing the required extension: GL_ARB_%s", #name); return NULL; }
|
||||||
CHECK(texture_storage); CHECK(texture_buffer_object_rgb32);
|
CHECK(texture_storage);
|
||||||
#undef CHECK
|
#undef CHECK
|
||||||
}
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
@ -697,7 +706,7 @@ int add_module_gl_constants(PyObject *module) {
|
|||||||
GLC(GL_TEXTURE_MIN_FILTER); GLC(GL_TEXTURE_MAG_FILTER);
|
GLC(GL_TEXTURE_MIN_FILTER); GLC(GL_TEXTURE_MAG_FILTER);
|
||||||
GLC(GL_TEXTURE_WRAP_S); GLC(GL_TEXTURE_WRAP_T);
|
GLC(GL_TEXTURE_WRAP_S); GLC(GL_TEXTURE_WRAP_T);
|
||||||
GLC(GL_UNPACK_ALIGNMENT);
|
GLC(GL_UNPACK_ALIGNMENT);
|
||||||
GLC(GL_R8); GLC(GL_RED); GLC(GL_UNSIGNED_BYTE); GLC(GL_RGB32UI); GLC(GL_RGBA);
|
GLC(GL_R8); GLC(GL_RED); GLC(GL_UNSIGNED_BYTE); GLC(GL_R32UI); GLC(GL_RGB32UI); GLC(GL_RGBA);
|
||||||
GLC(GL_TEXTURE_BUFFER); GLC(GL_STATIC_DRAW); GLC(GL_STREAM_DRAW);
|
GLC(GL_TEXTURE_BUFFER); GLC(GL_STATIC_DRAW); GLC(GL_STREAM_DRAW);
|
||||||
GLC(GL_SRC_ALPHA); GLC(GL_ONE_MINUS_SRC_ALPHA);
|
GLC(GL_SRC_ALPHA); GLC(GL_ONE_MINUS_SRC_ALPHA);
|
||||||
GLC(GL_BLEND); GLC(GL_FLOAT); GLC(GL_ARRAY_BUFFER);
|
GLC(GL_BLEND); GLC(GL_FLOAT); GLC(GL_ARRAY_BUFFER);
|
||||||
@ -716,6 +725,7 @@ int add_module_gl_constants(PyObject *module) {
|
|||||||
METH(GetProgramiv, METH_VARARGS) \
|
METH(GetProgramiv, METH_VARARGS) \
|
||||||
METH(GetShaderiv, METH_VARARGS) \
|
METH(GetShaderiv, METH_VARARGS) \
|
||||||
METH(Uniform2ui, METH_VARARGS) \
|
METH(Uniform2ui, METH_VARARGS) \
|
||||||
|
METH(Uniform2i, METH_VARARGS) \
|
||||||
METH(Uniform1i, METH_VARARGS) \
|
METH(Uniform1i, METH_VARARGS) \
|
||||||
METH(Uniform2f, METH_VARARGS) \
|
METH(Uniform2f, METH_VARARGS) \
|
||||||
METH(Uniform4f, METH_VARARGS) \
|
METH(Uniform4f, METH_VARARGS) \
|
||||||
|
|||||||
@ -209,6 +209,7 @@ def run_app(opts, args):
|
|||||||
window.set_title(appname)
|
window.set_title(appname)
|
||||||
window.make_context_current()
|
window.make_context_current()
|
||||||
if isosx:
|
if isosx:
|
||||||
|
check_for_extensions()
|
||||||
if opts.macos_hide_titlebar:
|
if opts.macos_hide_titlebar:
|
||||||
from .fast_data_types import cocoa_hide_titlebar
|
from .fast_data_types import cocoa_hide_titlebar
|
||||||
cocoa_hide_titlebar(window.cocoa_window_id())
|
cocoa_hide_titlebar(window.cocoa_window_id())
|
||||||
@ -220,8 +221,6 @@ def run_app(opts, args):
|
|||||||
viewport_size.x_ratio = viewport_size.width / float(w)
|
viewport_size.x_ratio = viewport_size.width / float(w)
|
||||||
viewport_size.y_ratio = viewport_size.height / float(h)
|
viewport_size.y_ratio = viewport_size.height / float(h)
|
||||||
glewInit()
|
glewInit()
|
||||||
if isosx:
|
|
||||||
check_for_extensions()
|
|
||||||
boss = Boss(window, opts, args)
|
boss = Boss(window, opts, args)
|
||||||
boss.start()
|
boss.start()
|
||||||
clear_buffers(window, opts)
|
clear_buffers(window, opts)
|
||||||
|
|||||||
@ -21,7 +21,7 @@ from .fast_data_types import (
|
|||||||
GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S,
|
GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S,
|
||||||
GL_NEAREST, GL_TEXTURE_WRAP_T, glGenBuffers, GL_R8, GL_RED,
|
GL_NEAREST, GL_TEXTURE_WRAP_T, glGenBuffers, GL_R8, GL_RED,
|
||||||
GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, GL_STATIC_DRAW, GL_STREAM_DRAW,
|
GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE, GL_STATIC_DRAW, GL_STREAM_DRAW,
|
||||||
GL_TEXTURE_BUFFER, GL_RGB32UI, GL_FLOAT, GL_ARRAY_BUFFER, glBindBuffer,
|
GL_TEXTURE_BUFFER, GL_R32UI, GL_FLOAT, GL_ARRAY_BUFFER, glBindBuffer,
|
||||||
glPixelStorei, glTexBuffer, glActiveTexture, glTexStorage3D,
|
glPixelStorei, glTexBuffer, glActiveTexture, glTexStorage3D,
|
||||||
glCopyImageSubData, glTexSubImage3D, ITALIC, BOLD, SpriteMap,
|
glCopyImageSubData, glTexSubImage3D, ITALIC, BOLD, SpriteMap,
|
||||||
glEnableVertexAttribArray, glVertexAttribPointer, copy_image_sub_data
|
glEnableVertexAttribArray, glVertexAttribPointer, copy_image_sub_data
|
||||||
@ -162,7 +162,7 @@ class Sprites:
|
|||||||
|
|
||||||
def bind_sprite_map(self, buf_id):
|
def bind_sprite_map(self, buf_id):
|
||||||
glBindBuffer(GL_TEXTURE_BUFFER, buf_id)
|
glBindBuffer(GL_TEXTURE_BUFFER, buf_id)
|
||||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGB32UI, buf_id)
|
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, buf_id)
|
||||||
|
|
||||||
def destroy_sprite_map(self, buf_id):
|
def destroy_sprite_map(self, buf_id):
|
||||||
glDeleteBuffer(buf_id)
|
glDeleteBuffer(buf_id)
|
||||||
@ -179,7 +179,7 @@ class Sprites:
|
|||||||
glBindTexture(GL_TEXTURE_2D_ARRAY, 0)
|
glBindTexture(GL_TEXTURE_2D_ARRAY, 0)
|
||||||
glBindTexture(GL_TEXTURE_BUFFER, 0)
|
glBindTexture(GL_TEXTURE_BUFFER, 0)
|
||||||
glBindBuffer(GL_TEXTURE_BUFFER, 0)
|
glBindBuffer(GL_TEXTURE_BUFFER, 0)
|
||||||
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGB32UI, 0)
|
glTexBuffer(GL_TEXTURE_BUFFER, GL_R32UI, 0)
|
||||||
|
|
||||||
|
|
||||||
class ShaderProgram:
|
class ShaderProgram:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user