Gawain: use ShaderInterface to manage uniforms
This eliminates tons of glGetUniformLocation calls from the drawing loop. Vast majority of code can keep making the same function calls. They're just faster now! - Batch_Uniform* - immUniform* - gpuBindMatrices - and others
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "vertex_buffer.h"
|
#include "vertex_buffer.h"
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
|
#include "shader_interface.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
READY_TO_FORMAT,
|
READY_TO_FORMAT,
|
||||||
@@ -38,6 +39,7 @@ typedef struct Batch {
|
|||||||
|
|
||||||
// state
|
// state
|
||||||
GLuint program;
|
GLuint program;
|
||||||
|
const ShaderInterface* interface;
|
||||||
} Batch;
|
} Batch;
|
||||||
|
|
||||||
Batch* Batch_create(PrimitiveType, VertexBuffer*, ElementList*);
|
Batch* Batch_create(PrimitiveType, VertexBuffer*, ElementList*);
|
||||||
@@ -48,7 +50,7 @@ void Batch_discard_all(Batch*); // including verts & elem
|
|||||||
|
|
||||||
int Batch_add_VertexBuffer(Batch*, VertexBuffer*);
|
int Batch_add_VertexBuffer(Batch*, VertexBuffer*);
|
||||||
|
|
||||||
void Batch_set_program(Batch*, GLuint program);
|
void Batch_set_program(Batch*, GLuint program, const ShaderInterface*);
|
||||||
// Entire batch draws with one shader program, but can be redrawn later with another program.
|
// Entire batch draws with one shader program, but can be redrawn later with another program.
|
||||||
// Vertex shader's inputs must be compatible with the batch's vertex format.
|
// Vertex shader's inputs must be compatible with the batch's vertex format.
|
||||||
|
|
||||||
|
@@ -13,13 +13,14 @@
|
|||||||
|
|
||||||
#include "vertex_format.h"
|
#include "vertex_format.h"
|
||||||
#include "primitive.h"
|
#include "primitive.h"
|
||||||
|
#include "shader_interface.h"
|
||||||
|
|
||||||
#define IMM_BATCH_COMBO 1
|
#define IMM_BATCH_COMBO 1
|
||||||
|
|
||||||
|
|
||||||
VertexFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib
|
VertexFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib
|
||||||
|
|
||||||
void immBindProgram(GLuint program); // every immBegin must have a program bound first
|
void immBindProgram(GLuint program, const ShaderInterface*); // every immBegin must have a program bound first
|
||||||
void immUnbindProgram(void); // call after your last immEnd, or before binding another program
|
void immUnbindProgram(void); // call after your last immEnd, or before binding another program
|
||||||
|
|
||||||
void immBegin(PrimitiveType, unsigned vertex_ct); // must supply exactly vertex_ct vertices
|
void immBegin(PrimitiveType, unsigned vertex_ct); // must supply exactly vertex_ct vertices
|
||||||
|
@@ -88,13 +88,14 @@ int Batch_add_VertexBuffer(Batch* batch, VertexBuffer* verts)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_set_program(Batch* batch, GLuint program)
|
void Batch_set_program(Batch* batch, GLuint program, const ShaderInterface* shaderface)
|
||||||
{
|
{
|
||||||
#if TRUST_NO_ONE
|
#if TRUST_NO_ONE
|
||||||
assert(glIsProgram(program));
|
assert(glIsProgram(program));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
batch->program = program;
|
batch->program = program;
|
||||||
|
batch->interface = shaderface;
|
||||||
batch->program_dirty = true;
|
batch->program_dirty = true;
|
||||||
|
|
||||||
Batch_use_program(batch); // hack! to make Batch_Uniform* simpler
|
Batch_use_program(batch); // hack! to make Batch_Uniform* simpler
|
||||||
@@ -172,92 +173,58 @@ void Batch_done_using_program(Batch* batch)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_Uniform1i(Batch* batch, const char* name, int value)
|
|
||||||
{
|
|
||||||
int loc = glGetUniformLocation(batch->program, name);
|
|
||||||
|
|
||||||
#if TRUST_NO_ONE
|
#if TRUST_NO_ONE
|
||||||
assert(loc != -1);
|
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(batch->interface, name); assert(uniform);
|
||||||
|
#else
|
||||||
|
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(batch->interface, name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glUniform1i(loc, value);
|
void Batch_Uniform1i(Batch* batch, const char* name, int value)
|
||||||
|
{
|
||||||
|
GET_UNIFORM
|
||||||
|
glUniform1i(uniform->location, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_Uniform1b(Batch* batch, const char* name, bool value)
|
void Batch_Uniform1b(Batch* batch, const char* name, bool value)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(batch->program, name);
|
GET_UNIFORM
|
||||||
|
glUniform1i(uniform->location, value ? GL_TRUE : GL_FALSE);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform1i(loc, value ? GL_TRUE : GL_FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_Uniform2f(Batch* batch, const char* name, float x, float y)
|
void Batch_Uniform2f(Batch* batch, const char* name, float x, float y)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(batch->program, name);
|
GET_UNIFORM
|
||||||
|
glUniform2f(uniform->location, x, y);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform2f(loc, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_Uniform3f(Batch* batch, const char* name, float x, float y, float z)
|
void Batch_Uniform3f(Batch* batch, const char* name, float x, float y, float z)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(batch->program, name);
|
GET_UNIFORM
|
||||||
|
glUniform3f(uniform->location, x, y, z);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform3f(loc, x, y, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_Uniform4f(Batch* batch, const char* name, float x, float y, float z, float w)
|
void Batch_Uniform4f(Batch* batch, const char* name, float x, float y, float z, float w)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(batch->program, name);
|
GET_UNIFORM
|
||||||
|
glUniform4f(uniform->location, x, y, z, w);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform4f(loc, x, y, z, w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_Uniform1f(Batch* batch, const char* name, float x)
|
void Batch_Uniform1f(Batch* batch, const char* name, float x)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(batch->program, name);
|
GET_UNIFORM
|
||||||
|
glUniform1f(uniform->location, x);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform1f(loc, x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_Uniform3fv(Batch* batch, const char* name, const float data[3])
|
void Batch_Uniform3fv(Batch* batch, const char* name, const float data[3])
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(batch->program, name);
|
GET_UNIFORM
|
||||||
|
glUniform3fv(uniform->location, 1, data);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform3fv(loc, 1, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Batch_Uniform4fv(Batch* batch, const char* name, const float data[4])
|
void Batch_Uniform4fv(Batch* batch, const char* name, const float data[4])
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(batch->program, name);
|
GET_UNIFORM
|
||||||
|
glUniform4fv(uniform->location, 1, data);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform4fv(loc, 1, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Batch_prime(Batch* batch)
|
static void Batch_prime(Batch* batch)
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// necessary functions from matrix API
|
// necessary functions from matrix API
|
||||||
extern void gpuBindMatrices(GLuint program);
|
extern void gpuBindMatrices(const ShaderInterface*);
|
||||||
extern bool gpuMatricesDirty(void);
|
extern bool gpuMatricesDirty(void);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -44,6 +44,7 @@ typedef struct {
|
|||||||
GLuint vao_id;
|
GLuint vao_id;
|
||||||
|
|
||||||
GLuint bound_program;
|
GLuint bound_program;
|
||||||
|
const ShaderInterface* shader_interface;
|
||||||
AttribBinding attrib_binding;
|
AttribBinding attrib_binding;
|
||||||
uint16_t prev_enabled_attrib_bits; // <-- only affects this VAO, so we're ok
|
uint16_t prev_enabled_attrib_bits; // <-- only affects this VAO, so we're ok
|
||||||
} Immediate;
|
} Immediate;
|
||||||
@@ -117,21 +118,22 @@ VertexFormat* immVertexFormat(void)
|
|||||||
return &imm.vertex_format;
|
return &imm.vertex_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
void immBindProgram(GLuint program)
|
void immBindProgram(GLuint program, const ShaderInterface* shaderface)
|
||||||
{
|
{
|
||||||
#if TRUST_NO_ONE
|
#if TRUST_NO_ONE
|
||||||
assert(imm.bound_program == 0);
|
assert(imm.bound_program == 0);
|
||||||
assert(glIsProgram(program));
|
assert(glIsProgram(program));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
imm.bound_program = program;
|
||||||
|
imm.shader_interface = shaderface;
|
||||||
|
|
||||||
if (!imm.vertex_format.packed)
|
if (!imm.vertex_format.packed)
|
||||||
VertexFormat_pack(&imm.vertex_format);
|
VertexFormat_pack(&imm.vertex_format);
|
||||||
|
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, program);
|
get_attrib_locations(&imm.vertex_format, &imm.attrib_binding, program);
|
||||||
imm.bound_program = program;
|
gpuBindMatrices(shaderface);
|
||||||
|
|
||||||
gpuBindMatrices(program);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUnbindProgram(void)
|
void immUnbindProgram(void)
|
||||||
@@ -267,7 +269,7 @@ Batch* immBeginBatch(PrimitiveType prim_type, unsigned vertex_ct)
|
|||||||
imm.batch = Batch_create(prim_type, verts, NULL);
|
imm.batch = Batch_create(prim_type, verts, NULL);
|
||||||
imm.batch->phase = BUILDING;
|
imm.batch->phase = BUILDING;
|
||||||
|
|
||||||
Batch_set_program(imm.batch, imm.bound_program);
|
Batch_set_program(imm.batch, imm.bound_program, imm.shader_interface);
|
||||||
|
|
||||||
return imm.batch;
|
return imm.batch;
|
||||||
}
|
}
|
||||||
@@ -336,7 +338,7 @@ static void immDrawSetup(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gpuMatricesDirty())
|
if (gpuMatricesDirty())
|
||||||
gpuBindMatrices(imm.bound_program);
|
gpuBindMatrices(imm.shader_interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void immEnd(void)
|
void immEnd(void)
|
||||||
@@ -716,126 +718,76 @@ void immVertex2iv(unsigned attrib_id, const int data[2])
|
|||||||
|
|
||||||
// --- generic uniform functions ---
|
// --- generic uniform functions ---
|
||||||
|
|
||||||
void immUniform1f(const char* name, float x)
|
|
||||||
{
|
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
|
||||||
|
|
||||||
#if TRUST_NO_ONE
|
#if TRUST_NO_ONE
|
||||||
assert(loc != -1);
|
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name); assert(uniform);
|
||||||
|
#else
|
||||||
|
#define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glUniform1f(loc, x);
|
void immUniform1f(const char* name, float x)
|
||||||
|
{
|
||||||
|
GET_UNIFORM
|
||||||
|
glUniform1f(uniform->location, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniform2f(const char* name, float x, float y)
|
void immUniform2f(const char* name, float x, float y)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform2f(uniform->location, x, y);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform2f(loc, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniform2fv(const char* name, const float data[2])
|
void immUniform2fv(const char* name, const float data[2])
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform2fv(uniform->location, 1, data);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform2fv(loc, 1, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniform3f(const char* name, float x, float y, float z)
|
void immUniform3f(const char* name, float x, float y, float z)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform3f(uniform->location, x, y, z);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform3f(loc, x, y, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniform3fv(const char* name, const float data[3])
|
void immUniform3fv(const char* name, const float data[3])
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform3fv(uniform->location, 1, data);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform3fv(loc, 1, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniformArray3fv(const char* name, const float *data, int count)
|
void immUniformArray3fv(const char* name, const float *data, int count)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform3fv(uniform->location, count, data);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
assert(count > 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform3fv(loc, count, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniform4f(const char* name, float x, float y, float z, float w)
|
void immUniform4f(const char* name, float x, float y, float z, float w)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform4f(uniform->location, x, y, z, w);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform4f(loc, x, y, z, w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniform4fv(const char* name, const float data[4])
|
void immUniform4fv(const char* name, const float data[4])
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform4fv(uniform->location, 1, data);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform4fv(loc, 1, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniformMatrix4fv(const char* name, const float data[4][4])
|
void immUniformMatrix4fv(const char* name, const float data[4][4])
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniformMatrix4fv(uniform->location, 1, GL_FALSE, (float *)data);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniformMatrix4fv(loc, 1, GL_FALSE, (float *)data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniform1i(const char* name, int x)
|
void immUniform1i(const char* name, int x)
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform1i(uniform->location, x);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform1i(loc, x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniform4iv(const char* name, const int data[4])
|
void immUniform4iv(const char* name, const int data[4])
|
||||||
{
|
{
|
||||||
int loc = glGetUniformLocation(imm.bound_program, name);
|
GET_UNIFORM
|
||||||
|
glUniform4iv(uniform->location, 1, data);
|
||||||
#if TRUST_NO_ONE
|
|
||||||
assert(loc != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glUniform4iv(loc, 1, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- convenience functions for setting "uniform vec4 color" ---
|
// --- convenience functions for setting "uniform vec4 color" ---
|
||||||
|
@@ -95,6 +95,7 @@ typedef struct OCIO_GLSLDrawState {
|
|||||||
GLuint ocio_shader;
|
GLuint ocio_shader;
|
||||||
GLuint vert_shader;
|
GLuint vert_shader;
|
||||||
GLuint program;
|
GLuint program;
|
||||||
|
ShaderInterface *shader_interface;
|
||||||
|
|
||||||
/* Previous OpenGL state. */
|
/* Previous OpenGL state. */
|
||||||
GLint last_texture, last_texture_unit;
|
GLint last_texture, last_texture_unit;
|
||||||
@@ -411,10 +412,12 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
|
|||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
immBindProgram(state->program);
|
state->shader_interface = ShaderInterface_create(state->program);
|
||||||
|
|
||||||
glUniform1i(glGetUniformLocation(state->program, "image_texture"), 0);
|
immBindProgram(state->program, state->shader_interface);
|
||||||
glUniform1i(glGetUniformLocation(state->program, "lut3d_texture"), 1);
|
|
||||||
|
immUniform1i("image_texture", 0);
|
||||||
|
immUniform1i("lut3d_texture", 1);
|
||||||
|
|
||||||
if (state->texture_size_used) {
|
if (state->texture_size_used) {
|
||||||
/* we use textureSize() if possible for best performance, if not
|
/* we use textureSize() if possible for best performance, if not
|
||||||
@@ -424,30 +427,30 @@ bool OCIOImpl::setupGLSLDraw(OCIO_GLSLDrawState **state_r, OCIO_ConstProcessorRc
|
|||||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
|
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
|
||||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
|
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
|
||||||
|
|
||||||
glUniform1f(glGetUniformLocation(state->program, "image_texture_width"), (float)width);
|
immUniform1f("image_texture_width", (float)width);
|
||||||
glUniform1f(glGetUniformLocation(state->program, "image_texture_height"), (float)height);
|
immUniform1f("image_texture_height", (float)height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_dither) {
|
if (use_dither) {
|
||||||
glUniform1f(glGetUniformLocation(state->program, "dither"), dither);
|
immUniform1f("dither", dither);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_curve_mapping) {
|
if (use_curve_mapping) {
|
||||||
glUniform1i(glGetUniformLocation(state->program, "curve_mapping_texture"), 2);
|
immUniform1i("curve_mapping_texture", 2);
|
||||||
glUniform1i(glGetUniformLocation(state->program, "curve_mapping_lut_size"), curve_mapping_settings->lut_size);
|
immUniform1i("curve_mapping_lut_size", curve_mapping_settings->lut_size);
|
||||||
glUniform4iv(glGetUniformLocation(state->program, "use_curve_mapping_extend_extrapolate"), 1, curve_mapping_settings->use_extend_extrapolate);
|
immUniform4iv("use_curve_mapping_extend_extrapolate", curve_mapping_settings->use_extend_extrapolate);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_mintable"), 1, curve_mapping_settings->mintable);
|
immUniform4fv("curve_mapping_mintable", curve_mapping_settings->mintable);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_range"), 1, curve_mapping_settings->range);
|
immUniform4fv("curve_mapping_range", curve_mapping_settings->range);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_ext_in_x"), 1, curve_mapping_settings->ext_in_x);
|
immUniform4fv("curve_mapping_ext_in_x", curve_mapping_settings->ext_in_x);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_ext_in_y"), 1, curve_mapping_settings->ext_in_y);
|
immUniform4fv("curve_mapping_ext_in_y", curve_mapping_settings->ext_in_y);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_ext_out_x"), 1, curve_mapping_settings->ext_out_x);
|
immUniform4fv("curve_mapping_ext_out_x", curve_mapping_settings->ext_out_x);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_ext_out_y"), 1, curve_mapping_settings->ext_out_y);
|
immUniform4fv("curve_mapping_ext_out_y", curve_mapping_settings->ext_out_y);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_first_x"), 1, curve_mapping_settings->first_x);
|
immUniform4fv("curve_mapping_first_x", curve_mapping_settings->first_x);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_first_y"), 1, curve_mapping_settings->first_y);
|
immUniform4fv("curve_mapping_first_y", curve_mapping_settings->first_y);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_last_x"), 1, curve_mapping_settings->last_x);
|
immUniform4fv("curve_mapping_last_x", curve_mapping_settings->last_x);
|
||||||
glUniform4fv(glGetUniformLocation(state->program, "curve_mapping_last_y"), 1, curve_mapping_settings->last_y);
|
immUniform4fv("curve_mapping_last_y", curve_mapping_settings->last_y);
|
||||||
glUniform3fv(glGetUniformLocation(state->program, "curve_mapping_black"), 1, curve_mapping_settings->black);
|
immUniform3fv("curve_mapping_black", curve_mapping_settings->black);
|
||||||
glUniform3fv(glGetUniformLocation(state->program, "curve_mapping_bwmul"), 1, curve_mapping_settings->bwmul);
|
immUniform3fv("curve_mapping_bwmul", curve_mapping_settings->bwmul);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -480,6 +483,9 @@ void OCIOImpl::freeGLState(struct OCIO_GLSLDrawState *state)
|
|||||||
if (state->program)
|
if (state->program)
|
||||||
glDeleteProgram(state->program);
|
glDeleteProgram(state->program);
|
||||||
|
|
||||||
|
if (state->shader_interface)
|
||||||
|
ShaderInterface_discard(state->shader_interface);
|
||||||
|
|
||||||
if (state->ocio_shader)
|
if (state->ocio_shader)
|
||||||
glDeleteShader(state->ocio_shader);
|
glDeleteShader(state->ocio_shader);
|
||||||
|
|
||||||
|
@@ -1002,7 +1002,7 @@ static void draw_geometry(DRWShadingGroup *shgroup, Batch *geom, const float (*o
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* step 2 : bind vertex array & draw */
|
/* step 2 : bind vertex array & draw */
|
||||||
Batch_set_program(geom, GPU_shader_get_program(shgroup->shader));
|
Batch_set_program(geom, GPU_shader_get_program(shgroup->shader), GPU_shader_get_interface(shgroup->shader));
|
||||||
if (interface->instance_vbo) {
|
if (interface->instance_vbo) {
|
||||||
Batch_draw_stupid_instanced(geom, interface->instance_vbo, interface->instance_count, interface->attribs_count,
|
Batch_draw_stupid_instanced(geom, interface->instance_vbo, interface->instance_count, interface->attribs_count,
|
||||||
interface->attribs_stride, interface->attribs_size, interface->attribs_loc);
|
interface->attribs_stride, interface->attribs_size, interface->attribs_loc);
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include "BLI_sys_types.h"
|
#include "BLI_sys_types.h"
|
||||||
#include "GPU_glew.h"
|
#include "GPU_glew.h"
|
||||||
|
#include "../../../intern/gawain/gawain/shader_interface.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -132,7 +133,7 @@ const float *gpuGetNormalMatrixInverse(float m[3][3]);
|
|||||||
|
|
||||||
|
|
||||||
/* set uniform values for currently bound shader */
|
/* set uniform values for currently bound shader */
|
||||||
void gpuBindMatrices(GLuint program);
|
void gpuBindMatrices(const ShaderInterface*);
|
||||||
bool gpuMatricesDirty(void); /* since last bind */
|
bool gpuMatricesDirty(void); /* since last bind */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
void Batch_set_builtin_program(Batch *batch, GPUBuiltinShader shader_id)
|
void Batch_set_builtin_program(Batch *batch, GPUBuiltinShader shader_id)
|
||||||
{
|
{
|
||||||
GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
|
GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
|
||||||
Batch_set_program(batch, shader->program);
|
Batch_set_program(batch, shader->program, shader->interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Batch *sphere_high = NULL;
|
static Batch *sphere_high = NULL;
|
||||||
|
@@ -734,7 +734,7 @@ void GPU_fx_compositor_XRay_resolve(GPUFX *fx)
|
|||||||
GPUDepthResolveInterface *interface = GPU_fx_shader_get_interface(depth_resolve_shader);
|
GPUDepthResolveInterface *interface = GPU_fx_shader_get_interface(depth_resolve_shader);
|
||||||
|
|
||||||
/* set up quad buffer */
|
/* set up quad buffer */
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(depth_resolve_shader));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(depth_resolve_shader), GPU_shader_get_interface(depth_resolve_shader));
|
||||||
|
|
||||||
GPU_texture_bind(fx->depth_buffer_xray, 0);
|
GPU_texture_bind(fx->depth_buffer_xray, 0);
|
||||||
GPU_texture_compare_mode(fx->depth_buffer_xray, false);
|
GPU_texture_compare_mode(fx->depth_buffer_xray, false);
|
||||||
@@ -838,7 +838,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
|
|
||||||
GPUSSAOShaderInterface *interface = GPU_fx_shader_get_interface(ssao_shader);
|
GPUSSAOShaderInterface *interface = GPU_fx_shader_get_interface(ssao_shader);
|
||||||
|
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(ssao_shader));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(ssao_shader), GPU_shader_get_interface(ssao_shader));
|
||||||
|
|
||||||
GPU_shader_uniform_vector(ssao_shader, interface->ssao_uniform, 4, 1, ssao_params);
|
GPU_shader_uniform_vector(ssao_shader, interface->ssao_uniform, 4, 1, ssao_params);
|
||||||
GPU_shader_uniform_vector(ssao_shader, interface->ssao_color_uniform, 4, 1, fx_ssao->color);
|
GPU_shader_uniform_vector(ssao_shader, interface->ssao_color_uniform, 4, 1, fx_ssao->color);
|
||||||
@@ -931,7 +931,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
|
|
||||||
GPUDOFHQPassOneInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass1);
|
GPUDOFHQPassOneInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass1);
|
||||||
|
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass1));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass1), GPU_shader_get_interface(dof_shader_pass1));
|
||||||
|
|
||||||
GPU_shader_uniform_vector(dof_shader_pass1, interface->dof_uniform, 4, 1, dof_params);
|
GPU_shader_uniform_vector(dof_shader_pass1, interface->dof_uniform, 4, 1, dof_params);
|
||||||
GPU_shader_uniform_vector(dof_shader_pass1, interface->invrendertargetdim_uniform, 2, 1, invrendertargetdim);
|
GPU_shader_uniform_vector(dof_shader_pass1, interface->invrendertargetdim_uniform, 2, 1, invrendertargetdim);
|
||||||
@@ -983,7 +983,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
|
|
||||||
GPUDOFHQPassTwoInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass2);
|
GPUDOFHQPassTwoInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass2);
|
||||||
|
|
||||||
Batch_set_program(fx->point_batch, GPU_shader_get_program(dof_shader_pass2));
|
Batch_set_program(fx->point_batch, GPU_shader_get_program(dof_shader_pass2), GPU_shader_get_interface(dof_shader_pass2));
|
||||||
|
|
||||||
GPU_texture_bind(fx->dof_nearfar_coc, numslots++);
|
GPU_texture_bind(fx->dof_nearfar_coc, numslots++);
|
||||||
GPU_texture_bind(fx->dof_half_downsampled_far, numslots++);
|
GPU_texture_bind(fx->dof_half_downsampled_far, numslots++);
|
||||||
@@ -1046,7 +1046,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
|
|
||||||
GPUDOFHQPassThreeInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass3);
|
GPUDOFHQPassThreeInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass3);
|
||||||
|
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass3));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass3), GPU_shader_get_interface(dof_shader_pass3));
|
||||||
|
|
||||||
GPU_shader_uniform_vector(dof_shader_pass3, interface->dof_uniform, 4, 1, dof_params);
|
GPU_shader_uniform_vector(dof_shader_pass3, interface->dof_uniform, 4, 1, dof_params);
|
||||||
|
|
||||||
@@ -1125,7 +1125,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
|
|
||||||
GPUDOFPassOneInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass1);
|
GPUDOFPassOneInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass1);
|
||||||
|
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass1));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass1), GPU_shader_get_interface(dof_shader_pass1));
|
||||||
|
|
||||||
GPU_shader_uniform_vector(dof_shader_pass1, interface->dof_uniform, 4, 1, dof_params);
|
GPU_shader_uniform_vector(dof_shader_pass1, interface->dof_uniform, 4, 1, dof_params);
|
||||||
GPU_shader_uniform_vector(dof_shader_pass1, interface->invrendertargetdim_uniform, 2, 1, invrendertargetdim);
|
GPU_shader_uniform_vector(dof_shader_pass1, interface->invrendertargetdim_uniform, 2, 1, invrendertargetdim);
|
||||||
@@ -1167,7 +1167,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
dof_params[2] = GPU_texture_width(fx->dof_near_coc_blurred_buffer) / (scale_camera * fx_dof->sensor);
|
dof_params[2] = GPU_texture_width(fx->dof_near_coc_blurred_buffer) / (scale_camera * fx_dof->sensor);
|
||||||
|
|
||||||
/* Blurring vertically */
|
/* Blurring vertically */
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass2));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass2), GPU_shader_get_interface(dof_shader_pass2));
|
||||||
|
|
||||||
GPU_shader_uniform_vector(dof_shader_pass2, interface->dof_uniform, 4, 1, dof_params);
|
GPU_shader_uniform_vector(dof_shader_pass2, interface->dof_uniform, 4, 1, dof_params);
|
||||||
GPU_shader_uniform_vector(dof_shader_pass2, interface->invrendertargetdim_uniform, 2, 1, invrendertargetdim);
|
GPU_shader_uniform_vector(dof_shader_pass2, interface->invrendertargetdim_uniform, 2, 1, invrendertargetdim);
|
||||||
@@ -1188,7 +1188,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
Batch_draw(fx->quad_batch);
|
Batch_draw(fx->quad_batch);
|
||||||
|
|
||||||
/* Rebind Shader */
|
/* Rebind Shader */
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass2));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass2), GPU_shader_get_interface(dof_shader_pass2));
|
||||||
|
|
||||||
/* *unbind/detach */
|
/* *unbind/detach */
|
||||||
GPU_texture_unbind(fx->dof_near_coc_buffer);
|
GPU_texture_unbind(fx->dof_near_coc_buffer);
|
||||||
@@ -1224,7 +1224,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
{
|
{
|
||||||
GPUDOFPassThreeInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass3);
|
GPUDOFPassThreeInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass3);
|
||||||
|
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass3));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass3), GPU_shader_get_interface(dof_shader_pass3));
|
||||||
|
|
||||||
GPU_texture_bind(fx->dof_near_coc_buffer, numslots++);
|
GPU_texture_bind(fx->dof_near_coc_buffer, numslots++);
|
||||||
GPU_shader_uniform_texture(dof_shader_pass3, interface->near_coc_downsampled, fx->dof_near_coc_buffer);
|
GPU_shader_uniform_texture(dof_shader_pass3, interface->near_coc_downsampled, fx->dof_near_coc_buffer);
|
||||||
@@ -1252,7 +1252,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
|
|
||||||
GPUDOFPassFourInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass4);
|
GPUDOFPassFourInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass4);
|
||||||
|
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass4));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass4), GPU_shader_get_interface(dof_shader_pass4));
|
||||||
|
|
||||||
GPU_texture_bind(fx->dof_near_coc_final_buffer, numslots++);
|
GPU_texture_bind(fx->dof_near_coc_final_buffer, numslots++);
|
||||||
GPU_shader_uniform_texture(dof_shader_pass4, interface->near_coc_downsampled, fx->dof_near_coc_final_buffer);
|
GPU_shader_uniform_texture(dof_shader_pass4, interface->near_coc_downsampled, fx->dof_near_coc_final_buffer);
|
||||||
@@ -1277,7 +1277,7 @@ bool GPU_fx_do_composite_pass(
|
|||||||
|
|
||||||
GPUDOFPassFiveInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass5);
|
GPUDOFPassFiveInterface *interface = GPU_fx_shader_get_interface(dof_shader_pass5);
|
||||||
|
|
||||||
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass5));
|
Batch_set_program(fx->quad_batch, GPU_shader_get_program(dof_shader_pass5), GPU_shader_get_interface(dof_shader_pass5));
|
||||||
|
|
||||||
GPU_shader_uniform_vector(dof_shader_pass5, interface->dof_uniform, 4, 1, dof_params);
|
GPU_shader_uniform_vector(dof_shader_pass5, interface->dof_uniform, 4, 1, dof_params);
|
||||||
GPU_shader_uniform_vector(dof_shader_pass5, interface->invrendertargetdim_uniform, 2, 1, invrendertargetdim);
|
GPU_shader_uniform_vector(dof_shader_pass5, interface->invrendertargetdim_uniform, 2, 1, invrendertargetdim);
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
|
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
|
||||||
{
|
{
|
||||||
GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
|
GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
|
||||||
immBindProgram(shader->program);
|
immBindProgram(shader->program, shader->interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void immUniformThemeColor(int color_id)
|
void immUniformThemeColor(int color_id)
|
||||||
|
@@ -829,74 +829,69 @@ const float *gpuGetNormalMatrixInverse(float m[3][3])
|
|||||||
return (const float*)m;
|
return (const float*)m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpuBindMatrices(GLuint program)
|
void gpuBindMatrices(const ShaderInterface* shaderface)
|
||||||
{
|
{
|
||||||
/* TODO: split this into 2 functions
|
/* set uniform values to matrix stack values
|
||||||
* 1) get uniform locations & determine 2D or 3D
|
* call this before a draw call if desired matrices are dirty
|
||||||
|
* call glUseProgram before this, as glUniform expects program to be bound
|
||||||
*/
|
*/
|
||||||
GLint loc_MV = glGetUniformLocation(program, "ModelViewMatrix");
|
|
||||||
GLint loc_P = glGetUniformLocation(program, "ProjectionMatrix");
|
|
||||||
GLint loc_MVP = glGetUniformLocation(program, "ModelViewProjectionMatrix");
|
|
||||||
GLint loc_N = glGetUniformLocation(program, "NormalMatrix");
|
|
||||||
|
|
||||||
/* 2) set uniform values to matrix stack values
|
const ShaderInput *MV = ShaderInterface_builtin_uniform(shaderface, UNIFORM_MODELVIEW_3D);
|
||||||
* program needs to be bound
|
const ShaderInput *P = ShaderInterface_builtin_uniform(shaderface, UNIFORM_PROJECTION_3D);
|
||||||
*/
|
const ShaderInput *MVP = ShaderInterface_builtin_uniform(shaderface, UNIFORM_MVP_3D);
|
||||||
glUseProgram(program);
|
const ShaderInput *N = ShaderInterface_builtin_uniform(shaderface, UNIFORM_NORMAL_3D);
|
||||||
|
|
||||||
|
if (MV) {
|
||||||
/* call this portion before a draw call if desired matrices are dirty */
|
|
||||||
if (loc_MV != -1) {
|
|
||||||
#if DEBUG_MATRIX_BIND
|
#if DEBUG_MATRIX_BIND
|
||||||
puts("setting 3D MV matrix");
|
puts("setting 3D MV matrix");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glUniformMatrix4fv(loc_MV, 1, GL_FALSE, gpuGetModelViewMatrix3D(NULL));
|
glUniformMatrix4fv(MV->location, 1, GL_FALSE, gpuGetModelViewMatrix3D(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loc_P != -1) {
|
if (P) {
|
||||||
#if DEBUG_MATRIX_BIND
|
#if DEBUG_MATRIX_BIND
|
||||||
puts("setting 3D P matrix");
|
puts("setting 3D P matrix");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glUniformMatrix4fv(loc_P, 1, GL_FALSE, gpuGetProjectionMatrix3D(NULL));
|
glUniformMatrix4fv(P->location, 1, GL_FALSE, gpuGetProjectionMatrix3D(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loc_MVP != -1) {
|
if (MVP) {
|
||||||
#if DEBUG_MATRIX_BIND
|
#if DEBUG_MATRIX_BIND
|
||||||
puts("setting 3D MVP matrix");
|
puts("setting 3D MVP matrix");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glUniformMatrix4fv(loc_MVP, 1, GL_FALSE, gpuGetModelViewProjectionMatrix3D(NULL));
|
glUniformMatrix4fv(MVP->location, 1, GL_FALSE, gpuGetModelViewProjectionMatrix3D(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loc_N != -1) {
|
if (N) {
|
||||||
#if DEBUG_MATRIX_BIND
|
#if DEBUG_MATRIX_BIND
|
||||||
puts("setting 3D normal matrix");
|
puts("setting 3D normal matrix");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glUniformMatrix3fv(loc_N, 1, GL_FALSE, gpuGetNormalMatrix(NULL));
|
glUniformMatrix3fv(N->location, 1, GL_FALSE, gpuGetNormalMatrix(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* also needed by material.glsl
|
/* also needed by material.glsl
|
||||||
* - ProjectionMatrixInverse
|
* - ProjectionMatrixInverse
|
||||||
* - ModelViewMatrixInverse
|
* - ModelViewMatrixInverse
|
||||||
*/
|
*/
|
||||||
GLint loc_MV_inv = glGetUniformLocation(program, "ModelViewInverseMatrix");
|
const ShaderInput *MV_inv = ShaderInterface_builtin_uniform(shaderface, UNIFORM_MODELVIEW_INV_3D);
|
||||||
GLint loc_P_inv = glGetUniformLocation(program, "ProjectionInverseMatrix");
|
const ShaderInput *P_inv = ShaderInterface_builtin_uniform(shaderface, UNIFORM_PROJECTION_INV_3D);
|
||||||
|
|
||||||
if (loc_MV_inv != -1) {
|
if (MV_inv) {
|
||||||
Mat4 m;
|
Mat4 m;
|
||||||
gpuGetModelViewMatrix3D(m);
|
gpuGetModelViewMatrix3D(m);
|
||||||
invert_m4(m);
|
invert_m4(m);
|
||||||
glUniformMatrix4fv(loc_MV_inv, 1, GL_FALSE, (const float*) m);
|
glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float*) m);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loc_P_inv != -1) {
|
if (P_inv) {
|
||||||
Mat4 m;
|
Mat4 m;
|
||||||
gpuGetProjectionMatrix3D(m);
|
gpuGetProjectionMatrix3D(m);
|
||||||
invert_m4(m);
|
invert_m4(m);
|
||||||
glUniformMatrix4fv(loc_P_inv, 1, GL_FALSE, (const float*) m);
|
glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float*) m);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.dirty = false;
|
state.dirty = false;
|
||||||
|
@@ -490,7 +490,7 @@ void GPU_shader_bind(GPUShader *shader)
|
|||||||
BLI_assert(shader && shader->program);
|
BLI_assert(shader && shader->program);
|
||||||
|
|
||||||
glUseProgram(shader->program);
|
glUseProgram(shader->program);
|
||||||
gpuBindMatrices(shader->program);
|
gpuBindMatrices(shader->interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_shader_unbind(void)
|
void GPU_shader_unbind(void)
|
||||||
|
Reference in New Issue
Block a user