[Bf-blender-cvs] [5ce4ce2e50d] tmp-eevee-material-refactor: GPUMaterial: Expose shader getter
Clément Foucault
noreply at git.blender.org
Thu May 14 16:58:55 CEST 2020
Commit: 5ce4ce2e50d892d57454b0d109d277db87aee862
Author: Clément Foucault
Date: Fri May 8 15:16:32 2020 +0200
Branches: tmp-eevee-material-refactor
https://developer.blender.org/rB5ce4ce2e50d892d57454b0d109d277db87aee862
GPUMaterial: Expose shader getter
===================================================================
M source/blender/gpu/GPU_material.h
M source/blender/gpu/intern/gpu_material.c
M source/blender/gpu/intern/gpu_texture.c
===================================================================
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 337c0b03308..c23960da1ed 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -190,6 +190,7 @@ void GPU_materials_free(struct Main *bmain);
struct Scene *GPU_material_scene(GPUMaterial *material);
struct GPUPass *GPU_material_get_pass(GPUMaterial *material);
+struct GPUShader *GPU_material_get_shader(GPUMaterial *material);
struct Material *GPU_material_get_material(GPUMaterial *material);
eGPUMaterialStatus GPU_material_status(GPUMaterial *mat);
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 97e4c880644..d2384b9c065 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -209,6 +209,11 @@ GPUPass *GPU_material_get_pass(GPUMaterial *material)
return material->pass;
}
+GPUShader *GPU_material_get_shader(GPUMaterial *material)
+{
+ return material->pass ? GPU_pass_shader_get(material->pass) : NULL;
+}
+
/* Return can be NULL if it's a world material. */
Material *GPU_material_get_material(GPUMaterial *material)
{
@@ -662,6 +667,9 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
/* Caller must re-use materials. */
BLI_assert(GPU_material_from_nodetree_find(gpumaterials, engine_type, options) == NULL);
+ /* HACK: Eevee assume this to create Ghash keys. */
+ BLI_assert(sizeof(GPUPass) > 16);
+
/* allocate material */
GPUMaterial *mat = MEM_callocN(sizeof(GPUMaterial), "GPUMaterial");
mat->ma = ma;
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index fd01ddf8597..6b454f054cf 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -1576,6 +1576,7 @@ void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat gpu_data_format, const vo
glClearTexImage(tex->bindcode, 0, data_format, data_type, color);
}
else {
+ /* TODO(fclem) speedup using the copy framebuffer. */
size_t buffer_len = gpu_texture_memory_footprint_compute(tex);
unsigned char *pixels = MEM_mallocN(buffer_len, __func__);
if (color) {
More information about the Bf-blender-cvs
mailing list