Skip to content

Commit

Permalink
Merge pull request #1664 from heinezen/feature/shader_update_optimize
Browse files Browse the repository at this point in the history
Vectorize uniform inputs
  • Loading branch information
TheJJ authored Aug 2, 2024
2 parents 7785b44 + e57f865 commit 99e355e
Show file tree
Hide file tree
Showing 14 changed files with 395 additions and 355 deletions.
4 changes: 3 additions & 1 deletion libopenage/renderer/opengl/context.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2015-2023 the openage authors. See copying.md for legal info.
// Copyright 2015-2024 the openage authors. See copying.md for legal info.

#include <array>
#include <epoxy/gl.h>
Expand Down Expand Up @@ -74,6 +74,8 @@ gl_context_spec GlContext::find_spec() {
caps.max_texture_slots = temp;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &temp);
caps.max_vertex_attributes = temp;
glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &temp);
caps.max_uniform_locations = temp;
glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &temp);
caps.max_uniform_buffer_bindings = temp;

Expand Down
2 changes: 2 additions & 0 deletions libopenage/renderer/opengl/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct gl_context_spec {
size_t max_texture_slots;
/// The maximum size of a single dimension of a texture.
size_t max_texture_size;
/// The maximum number of uniform locations per shader.
size_t max_uniform_locations;
/// The maximum number of binding points for uniform blocks
/// in a single shader.
size_t max_uniform_buffer_bindings;
Expand Down
6 changes: 5 additions & 1 deletion libopenage/renderer/opengl/lookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ static constexpr auto GL_UNIFORM_TYPE_SIZE = datastructure::create_const_map<GLe
std::pair(GL_FLOAT_VEC2, 8),
std::pair(GL_FLOAT_VEC3, 12),
std::pair(GL_FLOAT_VEC4, 16),
std::pair(GL_DOUBLE, 8),
std::pair(GL_DOUBLE_VEC2, 16),
std::pair(GL_DOUBLE_VEC3, 24),
std::pair(GL_DOUBLE_VEC4, 32),
std::pair(GL_INT, 4),
std::pair(GL_INT_VEC2, 8),
std::pair(GL_INT_VEC3, 12),
Expand Down Expand Up @@ -137,7 +141,7 @@ static constexpr auto GL_PRIMITIVE = datastructure::create_const_map<resources::
std::pair(resources::vertex_primitive_t::POINTS, GL_POINTS),
std::pair(resources::vertex_primitive_t::LINES, GL_LINES),
std::pair(resources::vertex_primitive_t::LINE_STRIP, GL_LINE_STRIP),
std::pair(resources::vertex_primitive_t::LINE_LOOP, GL_LINE_LOOP),
std::pair(resources::vertex_primitive_t::LINE_LOOP, GL_LINE_LOOP),
std::pair(resources::vertex_primitive_t::TRIANGLES, GL_TRIANGLES),
std::pair(resources::vertex_primitive_t::TRIANGLE_STRIP, GL_TRIANGLE_STRIP),
std::pair(resources::vertex_primitive_t::TRIANGLE_FAN, GL_TRIANGLE_FAN));
Expand Down
8 changes: 8 additions & 0 deletions libopenage/renderer/opengl/shader_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#pragma once

#include <optional>
#include <string>
#include <unordered_map>

Expand All @@ -22,6 +23,13 @@ struct GlUniform {
* NOT the same as the uniform index.
*/
GLuint location;

/**
* Only used for sampler uniforms.
*
* Texture unit to which the sampler is bound.
*/
std::optional<GLuint> tex_unit;
};

/**
Expand Down
Loading

0 comments on commit 99e355e

Please sign in to comment.