Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/GPU_shader_interface.h
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | typedef enum { | ||||
| GPU_UNIFORM_SRGB_TRANSFORM, /* bool srgbTarget */ | GPU_UNIFORM_SRGB_TRANSFORM, /* bool srgbTarget */ | ||||
| GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ | GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */ | ||||
| GPU_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ | GPU_NUM_UNIFORMS, /* Special value, denotes number of builtin uniforms. */ | ||||
| } GPUUniformBuiltin; | } GPUUniformBuiltin; | ||||
| typedef struct GPUShaderInput { | typedef struct GPUShaderInput { | ||||
| struct GPUShaderInput *next; | |||||
| uint32_t name_offset; | uint32_t name_offset; | ||||
| uint name_hash; | uint32_t name_hash; | ||||
| /** Only for uniform inputs. */ | |||||
| GPUUniformBuiltin builtin_type; | |||||
| /** Only for attribute inputs. */ | |||||
| uint32_t gl_type; | |||||
| /** Only for attribute inputs. */ | |||||
| int32_t size; | |||||
| int32_t location; | int32_t location; | ||||
| /** Defined at interface creation or in shader. Only for Samplers, UBOs and Vertex Attribs. */ | |||||
| int32_t binding; | |||||
| } GPUShaderInput; | } GPUShaderInput; | ||||
| #define GPU_NUM_SHADERINTERFACE_BUCKETS 257 | |||||
| #define GPU_SHADERINTERFACE_REF_ALLOC_COUNT 16 | #define GPU_SHADERINTERFACE_REF_ALLOC_COUNT 16 | ||||
| typedef struct GPUShaderInterface { | typedef struct GPUShaderInterface { | ||||
| int32_t program; | /** Buffer containing all inputs names separated by '\0'. */ | ||||
| uint32_t name_buffer_offset; | |||||
| GPUShaderInput *attr_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; | |||||
| GPUShaderInput *uniform_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; | |||||
| GPUShaderInput *ubo_buckets[GPU_NUM_SHADERINTERFACE_BUCKETS]; | |||||
| GPUShaderInput *builtin_uniforms[GPU_NUM_UNIFORMS]; | |||||
| char *name_buffer; | char *name_buffer; | ||||
| struct GPUBatch **batches; /* references to batches using this interface */ | /** Reference to GPUBatches using this interface */ | ||||
| struct GPUBatch **batches; | |||||
| uint batches_len; | uint batches_len; | ||||
| /** All enabled attributes in this shader. Used to set default values for unbound attributes. */ | /** Input counts. */ | ||||
| uint attribute_len; | |||||
| uint ubo_len; | |||||
| uint uniform_len; | |||||
| /** Enabled bindpoints that needs to be fed with data. */ | |||||
| uint16_t enabled_attr_mask; | uint16_t enabled_attr_mask; | ||||
| uint16_t enabled_ubo_mask; | |||||
| uint64_t enabled_tex_mask; | |||||
| /** Opengl Location of builtin uniforms. Fast access, no lookup needed. */ | |||||
| /* TODO replace by location only array. */ | |||||
| GPUShaderInput builtins[GPU_NUM_UNIFORMS]; | |||||
| /** Flat array. In this order: Attributes, Ubos, Uniforms. */ | |||||
| GPUShaderInput inputs[0]; | |||||
| } GPUShaderInterface; | } GPUShaderInterface; | ||||
| GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id); | GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id); | ||||
| void GPU_shaderinterface_discard(GPUShaderInterface *); | void GPU_shaderinterface_discard(GPUShaderInterface *); | ||||
| const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *, const char *name); | const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *, const char *name); | ||||
| const GPUShaderInput *GPU_shaderinterface_uniform_ensure(const GPUShaderInterface *, | const GPUShaderInput *GPU_shaderinterface_uniform_ensure(const GPUShaderInterface *, | ||||
| const char *name); | const char *name); | ||||
| Show All 14 Lines | |||||