Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_codegen.c
| Show First 20 Lines • Show All 2,125 Lines • ▼ Show 20 Lines | GPUPass *GPU_generate_pass(GPUMaterial *material, | ||||
| } | } | ||||
| return pass; | return pass; | ||||
| } | } | ||||
| static int count_active_texture_sampler(GPUShader *shader, char *source) | static int count_active_texture_sampler(GPUShader *shader, char *source) | ||||
| { | { | ||||
| char *code = source; | char *code = source; | ||||
| int samplers_id[64]; /* Remember this is per stage. */ | |||||
| int sampler_len = 0; | /* Remember this is per stage. */ | ||||
| GSet *sampler_ids = BLI_gset_int_new(__func__); | |||||
| int num_samplers = 0; | |||||
| while ((code = strstr(code, "uniform "))) { | while ((code = strstr(code, "uniform "))) { | ||||
| /* Move past "uniform". */ | /* Move past "uniform". */ | ||||
| code += 7; | code += 7; | ||||
| /* Skip following spaces. */ | /* Skip following spaces. */ | ||||
| while (*code == ' ') { | while (*code == ' ') { | ||||
| code++; | code++; | ||||
| } | } | ||||
| Show All 18 Lines | if (gpu_str_prefix(code, "sampler")) { | ||||
| char sampler_name[64]; | char sampler_name[64]; | ||||
| code = gpu_str_skip_token(code, sampler_name, sizeof(sampler_name)); | code = gpu_str_skip_token(code, sampler_name, sizeof(sampler_name)); | ||||
| int id = GPU_shader_get_uniform_ensure(shader, sampler_name); | int id = GPU_shader_get_uniform_ensure(shader, sampler_name); | ||||
| if (id == -1) { | if (id == -1) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Catch duplicates. */ | /* Catch duplicates. */ | ||||
| bool is_duplicate = false; | if (BLI_gset_add(sampler_ids, POINTER_FROM_INT(id))) { | ||||
| for (int i = 0; i < sampler_len; i++) { | num_samplers++; | ||||
| if (samplers_id[i] == id) { | |||||
| is_duplicate = true; | |||||
| } | |||||
| } | |||||
| if (!is_duplicate) { | |||||
| samplers_id[sampler_len] = id; | |||||
| sampler_len++; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return sampler_len; | BLI_gset_free(sampler_ids, NULL); | ||||
| return num_samplers; | |||||
| } | } | ||||
| static bool gpu_pass_shader_validate(GPUPass *pass, GPUShader *shader) | static bool gpu_pass_shader_validate(GPUPass *pass, GPUShader *shader) | ||||
| { | { | ||||
| if (shader == NULL) { | if (shader == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines | |||||