Skip to content

Commit 99e355e

Browse files
authored
Merge pull request #1664 from heinezen/feature/shader_update_optimize
Vectorize uniform inputs
2 parents 7785b44 + e57f865 commit 99e355e

File tree

14 files changed

+395
-355
lines changed

14 files changed

+395
-355
lines changed

libopenage/renderer/opengl/context.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015-2023 the openage authors. See copying.md for legal info.
1+
// Copyright 2015-2024 the openage authors. See copying.md for legal info.
22

33
#include <array>
44
#include <epoxy/gl.h>
@@ -74,6 +74,8 @@ gl_context_spec GlContext::find_spec() {
7474
caps.max_texture_slots = temp;
7575
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &temp);
7676
caps.max_vertex_attributes = temp;
77+
glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &temp);
78+
caps.max_uniform_locations = temp;
7779
glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &temp);
7880
caps.max_uniform_buffer_bindings = temp;
7981

libopenage/renderer/opengl/context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ struct gl_context_spec {
2424
size_t max_texture_slots;
2525
/// The maximum size of a single dimension of a texture.
2626
size_t max_texture_size;
27+
/// The maximum number of uniform locations per shader.
28+
size_t max_uniform_locations;
2729
/// The maximum number of binding points for uniform blocks
2830
/// in a single shader.
2931
size_t max_uniform_buffer_bindings;

libopenage/renderer/opengl/lookup.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ static constexpr auto GL_UNIFORM_TYPE_SIZE = datastructure::create_const_map<GLe
3333
std::pair(GL_FLOAT_VEC2, 8),
3434
std::pair(GL_FLOAT_VEC3, 12),
3535
std::pair(GL_FLOAT_VEC4, 16),
36+
std::pair(GL_DOUBLE, 8),
37+
std::pair(GL_DOUBLE_VEC2, 16),
38+
std::pair(GL_DOUBLE_VEC3, 24),
39+
std::pair(GL_DOUBLE_VEC4, 32),
3640
std::pair(GL_INT, 4),
3741
std::pair(GL_INT_VEC2, 8),
3842
std::pair(GL_INT_VEC3, 12),
@@ -137,7 +141,7 @@ static constexpr auto GL_PRIMITIVE = datastructure::create_const_map<resources::
137141
std::pair(resources::vertex_primitive_t::POINTS, GL_POINTS),
138142
std::pair(resources::vertex_primitive_t::LINES, GL_LINES),
139143
std::pair(resources::vertex_primitive_t::LINE_STRIP, GL_LINE_STRIP),
140-
std::pair(resources::vertex_primitive_t::LINE_LOOP, GL_LINE_LOOP),
144+
std::pair(resources::vertex_primitive_t::LINE_LOOP, GL_LINE_LOOP),
141145
std::pair(resources::vertex_primitive_t::TRIANGLES, GL_TRIANGLES),
142146
std::pair(resources::vertex_primitive_t::TRIANGLE_STRIP, GL_TRIANGLE_STRIP),
143147
std::pair(resources::vertex_primitive_t::TRIANGLE_FAN, GL_TRIANGLE_FAN));

libopenage/renderer/opengl/shader_data.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#pragma once
44

5+
#include <optional>
56
#include <string>
67
#include <unordered_map>
78

@@ -22,6 +23,13 @@ struct GlUniform {
2223
* NOT the same as the uniform index.
2324
*/
2425
GLuint location;
26+
27+
/**
28+
* Only used for sampler uniforms.
29+
*
30+
* Texture unit to which the sampler is bound.
31+
*/
32+
std::optional<GLuint> tex_unit;
2533
};
2634

2735
/**

0 commit comments

Comments
 (0)