GLRefactor: Remove all GL types from gawains public headers.
In preparation for possible alternative back-ends, the dependency on glew.h needs to be confined to as few libraries as possible. This patch removes all gl types from the public gawain headers. It'll need some more refactoring later on, but for now this will suffice. Reviewer: brecht, fclem Differential Revision: https://developer.blender.org/D3482
This commit is contained in:
parent
c90d348e04
commit
45591cc0df
|
@ -31,11 +31,11 @@ typedef struct Gwn_Batch {
|
|||
Gwn_VertBuf* verts[GWN_BATCH_VBO_MAX_LEN]; // verts[0] is required, others can be NULL
|
||||
Gwn_VertBuf* inst; // instance attribs
|
||||
Gwn_IndexBuf* elem; // NULL if element list not needed
|
||||
GLenum gl_prim_type;
|
||||
uint32_t gl_prim_type;
|
||||
|
||||
// cached values (avoid dereferencing later)
|
||||
GLuint vao_id;
|
||||
GLuint program;
|
||||
uint32_t vao_id;
|
||||
uint32_t program;
|
||||
const struct Gwn_ShaderInterface* interface;
|
||||
|
||||
// book-keeping
|
||||
|
@ -52,13 +52,13 @@ typedef struct Gwn_Batch {
|
|||
// Static handle count
|
||||
struct {
|
||||
const struct Gwn_ShaderInterface* interfaces[GWN_BATCH_VAO_STATIC_LEN];
|
||||
GLuint vao_ids[GWN_BATCH_VAO_STATIC_LEN];
|
||||
uint32_t vao_ids[GWN_BATCH_VAO_STATIC_LEN];
|
||||
} static_vaos;
|
||||
// Dynamic handle count
|
||||
struct {
|
||||
unsigned count;
|
||||
const struct Gwn_ShaderInterface** interfaces;
|
||||
GLuint* vao_ids;
|
||||
uint32_t* vao_ids;
|
||||
} dynamic_vaos;
|
||||
};
|
||||
|
||||
|
@ -95,8 +95,8 @@ int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo);
|
|||
#define GWN_batch_vertbuf_add(batch, verts) \
|
||||
GWN_batch_vertbuf_add_ex(batch, verts, false)
|
||||
|
||||
void GWN_batch_program_set_no_use(Gwn_Batch*, GLuint program, const Gwn_ShaderInterface*);
|
||||
void GWN_batch_program_set(Gwn_Batch*, GLuint program, const Gwn_ShaderInterface*);
|
||||
void GWN_batch_program_set_no_use(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*);
|
||||
void GWN_batch_program_set(Gwn_Batch*, uint32_t program, const Gwn_ShaderInterface*);
|
||||
// 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.
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ typedef struct Gwn_IndexBuf {
|
|||
unsigned index_ct;
|
||||
#if GWN_TRACK_INDEX_RANGE
|
||||
Gwn_IndexBufType index_type;
|
||||
GLenum gl_index_type;
|
||||
uint32_t gl_index_type;
|
||||
unsigned min_index;
|
||||
unsigned max_index;
|
||||
unsigned base_index;
|
||||
#endif
|
||||
GLuint vbo_id; // 0 indicates not yet sent to VRAM
|
||||
uint32_t vbo_id; // 0 indicates not yet sent to VRAM
|
||||
bool use_prim_restart;
|
||||
} Gwn_IndexBuf;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
Gwn_VertFormat* immVertexFormat(void); // returns a cleared vertex format, ready for add_attrib
|
||||
|
||||
void immBindProgram(GLuint program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first
|
||||
void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first
|
||||
void immUnbindProgram(void); // call after your last immEnd, or before binding another program
|
||||
|
||||
void immBegin(Gwn_PrimType, unsigned vertex_ct); // must supply exactly vertex_ct vertices
|
||||
|
|
|
@ -48,16 +48,16 @@ typedef struct Gwn_ShaderInput {
|
|||
uint32_t name_offset;
|
||||
unsigned name_hash;
|
||||
Gwn_UniformBuiltin builtin_type; // only for uniform inputs
|
||||
GLenum gl_type; // only for attrib inputs
|
||||
GLint size; // only for attrib inputs
|
||||
GLint location;
|
||||
uint32_t gl_type; // only for attrib inputs
|
||||
int32_t size; // only for attrib inputs
|
||||
int32_t location;
|
||||
} Gwn_ShaderInput;
|
||||
|
||||
#define GWN_NUM_SHADERINTERFACE_BUCKETS 257
|
||||
#define GWN_SHADERINTERFACE_REF_ALLOC_COUNT 16
|
||||
|
||||
typedef struct Gwn_ShaderInterface {
|
||||
GLint program;
|
||||
int32_t program;
|
||||
uint32_t name_buffer_offset;
|
||||
Gwn_ShaderInput* attrib_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
|
||||
Gwn_ShaderInput* uniform_buckets[GWN_NUM_SHADERINTERFACE_BUCKETS];
|
||||
|
@ -68,7 +68,7 @@ typedef struct Gwn_ShaderInterface {
|
|||
unsigned batches_ct;
|
||||
} Gwn_ShaderInterface;
|
||||
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program_id);
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id);
|
||||
void GWN_shaderinterface_discard(Gwn_ShaderInterface*);
|
||||
|
||||
const Gwn_ShaderInput* GWN_shaderinterface_uniform(const Gwn_ShaderInterface*, const char* name);
|
||||
|
|
|
@ -34,8 +34,8 @@ typedef struct Gwn_VertBuf {
|
|||
unsigned vertex_ct; // number of verts we want to draw
|
||||
unsigned vertex_alloc; // number of verts data
|
||||
bool dirty;
|
||||
GLubyte* data; // NULL indicates data in VRAM (unmapped)
|
||||
GLuint vbo_id; // 0 indicates not yet allocated
|
||||
uchar* data; // NULL indicates data in VRAM (unmapped)
|
||||
uint32_t vbo_id; // 0 indicates not yet allocated
|
||||
Gwn_UsageType usage; // usage hint for GL optimisation
|
||||
} Gwn_VertBuf;
|
||||
|
||||
|
@ -71,17 +71,17 @@ void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf*, unsigned a_idx, unsigned stride,
|
|||
typedef struct Gwn_VertBufRaw {
|
||||
unsigned size;
|
||||
unsigned stride;
|
||||
GLubyte* data;
|
||||
GLubyte* data_init;
|
||||
uchar* data;
|
||||
uchar* data_init;
|
||||
#if TRUST_NO_ONE
|
||||
// Only for overflow check
|
||||
GLubyte* _data_end;
|
||||
uchar* _data_end;
|
||||
#endif
|
||||
} Gwn_VertBufRaw;
|
||||
|
||||
GWN_INLINE void *GWN_vertbuf_raw_step(Gwn_VertBufRaw *a)
|
||||
{
|
||||
GLubyte* data = a->data;
|
||||
uchar* data = a->data;
|
||||
a->data += a->stride;
|
||||
#if TRUST_NO_ONE
|
||||
assert(data < a->_data_end);
|
||||
|
|
|
@ -283,7 +283,7 @@ static GLuint batch_vao_get(Gwn_Batch *batch)
|
|||
return new_vao;
|
||||
}
|
||||
|
||||
void GWN_batch_program_set_no_use(Gwn_Batch* batch, GLuint program, const Gwn_ShaderInterface* shaderface)
|
||||
void GWN_batch_program_set_no_use(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface)
|
||||
{
|
||||
#if TRUST_NO_ONE
|
||||
assert(glIsProgram(shaderface->program));
|
||||
|
@ -295,7 +295,7 @@ void GWN_batch_program_set_no_use(Gwn_Batch* batch, GLuint program, const Gwn_Sh
|
|||
batch->vao_id = batch_vao_get(batch);
|
||||
}
|
||||
|
||||
void GWN_batch_program_set(Gwn_Batch* batch, GLuint program, const Gwn_ShaderInterface* shaderface)
|
||||
void GWN_batch_program_set(Gwn_Batch* batch, uint32_t program, const Gwn_ShaderInterface* shaderface)
|
||||
{
|
||||
GWN_batch_program_set_no_use(batch, program, shaderface);
|
||||
GWN_batch_program_use_begin(batch); // hack! to make Batch_Uniform* simpler
|
||||
|
|
|
@ -193,7 +193,7 @@ static const Gwn_ShaderInput* add_uniform(Gwn_ShaderInterface* shaderface, const
|
|||
return input;
|
||||
}
|
||||
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(GLint program)
|
||||
Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program)
|
||||
{
|
||||
Gwn_ShaderInterface* shaderface = calloc(1, sizeof(Gwn_ShaderInterface));
|
||||
shaderface->program = program;
|
||||
|
|
Loading…
Reference in New Issue