Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c2
-rw-r--r--source/blender/gpu/intern/gpu_codegen.cc50
-rw-r--r--source/blender/gpu/intern/gpu_material.c10
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.c138
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.h9
-rw-r--r--source/blender/gpu/intern/gpu_shader_builtin.c13
-rw-r--r--source/blender/gpu/intern/gpu_shader_create_info.hh4
7 files changed, 58 insertions, 168 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 110fdfbd2d9..fed998bb33e 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -207,7 +207,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
int update_flags)
{
const MPropCol *vtcol = vcol_type == CD_PROP_COLOR ? vcol_data : NULL;
- const MLoopCol *vcol = vcol_type == CD_MLOOPCOL ? vcol_data : NULL;
+ const MLoopCol *vcol = vcol_type == CD_PROP_BYTE_COLOR ? vcol_data : NULL;
const float(*f3col)[3] = vcol_type == CD_PROP_FLOAT3 ? vcol_data : NULL;
const bool color_loops = vcol_domain == ATTR_DOMAIN_CORNER;
diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc
index 8963fa45c96..048928b2312 100644
--- a/source/blender/gpu/intern/gpu_codegen.cc
+++ b/source/blender/gpu/intern/gpu_codegen.cc
@@ -49,7 +49,6 @@ using namespace blender::gpu::shader;
struct GPUCodegenCreateInfo : ShaderCreateInfo {
struct NameBuffer {
- char attr_names[16][GPU_MAX_SAFE_ATTR_NAME + 1];
char var_names[16][8];
};
@@ -171,10 +170,6 @@ static std::ostream &operator<<(std::ostream &stream, const GPUInput *input)
return stream << input->texture->sampler_name;
case GPU_SOURCE_TEX_TILED_MAPPING:
return stream << input->texture->tiled_mapping_name;
- case GPU_SOURCE_VOLUME_GRID:
- return stream << input->volume_grid->sampler_name;
- case GPU_SOURCE_VOLUME_GRID_TRANSFORM:
- return stream << input->volume_grid->transform_name;
default:
BLI_assert(0);
return stream;
@@ -276,28 +271,6 @@ class GPUCodegen {
}
};
-static char attr_prefix_get(CustomDataType type)
-{
- switch (type) {
- case CD_MTFACE:
- return 'u';
- case CD_TANGENT:
- return 't';
- case CD_MCOL:
- case CD_MLOOPCOL:
- return 'c';
- case CD_PROP_COLOR:
- return 'c';
- case CD_AUTO_FROM_NAME:
- return 'a';
- case CD_HAIRLENGTH:
- return 'l';
- default:
- BLI_assert_msg(0, "GPUVertAttr Prefix type not found : This should not happen!");
- return '\0';
- }
-}
-
void GPUCodegen::generate_attribs()
{
if (BLI_listbase_is_empty(&graph.attributes)) {
@@ -317,24 +290,9 @@ void GPUCodegen::generate_attribs()
int slot = 15;
LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph.attributes) {
-
- /* NOTE: Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */
- if (attr->type == CD_ORCO) {
- /* OPTI: orco is computed from local positions, but only if no modifier is present. */
- STRNCPY(info.name_buffer->attr_names[slot], "orco");
- }
- else {
- char *name = info.name_buffer->attr_names[slot];
- name[0] = attr_prefix_get(static_cast<CustomDataType>(attr->type));
- name[1] = '\0';
- if (attr->name[0] != '\0') {
- /* XXX FIXME: see notes in mesh_render_data_create() */
- GPU_vertformat_safe_attr_name(attr->name, &name[1], GPU_MAX_SAFE_ATTR_NAME);
- }
- }
SNPRINTF(info.name_buffer->var_names[slot], "v%d", attr->id);
- blender::StringRefNull attr_name = info.name_buffer->attr_names[slot];
+ blender::StringRefNull attr_name = attr->input_name;
blender::StringRefNull var_name = info.name_buffer->var_names[slot];
eGPUType input_type, iface_type;
@@ -395,12 +353,6 @@ void GPUCodegen::generate_resources()
info.sampler(0, ImageType::FLOAT_2D, tex->sampler_name, Frequency::BATCH);
}
}
- /* Volume Grids. */
- LISTBASE_FOREACH (GPUMaterialVolumeGrid *, grid, &graph.volume_grids) {
- info.sampler(0, ImageType::FLOAT_3D, grid->sampler_name, Frequency::BATCH);
- /* TODO(@fclem): Global uniform. To put in an UBO. */
- info.push_constant(Type::MAT4, grid->transform_name);
- }
if (!BLI_listbase_is_empty(&ubo_inputs_)) {
/* NOTE: generate_uniform_buffer() should have sorted the inputs before this. */
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 711a3943a25..3d5e9723103 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -219,11 +219,6 @@ ListBase GPU_material_textures(GPUMaterial *material)
return material->graph.textures;
}
-ListBase GPU_material_volume_grids(GPUMaterial *material)
-{
- return material->graph.volume_grids;
-}
-
GPUUniformAttrList *GPU_material_uniform_attributes(GPUMaterial *material)
{
GPUUniformAttrList *attrs = &material->graph.uniform_attrs;
@@ -599,11 +594,6 @@ void GPU_material_status_set(GPUMaterial *mat, eGPUMaterialStatus status)
/* Code generation */
-bool GPU_material_is_volume_shader(GPUMaterial *mat)
-{
- return mat->is_volume_shader;
-}
-
bool GPU_material_has_surface_output(GPUMaterial *mat)
{
return mat->has_surface_output;
diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c
index d9143a12d5b..7f96a3b01c4 100644
--- a/source/blender/gpu/intern/gpu_node_graph.c
+++ b/source/blender/gpu/intern/gpu_node_graph.c
@@ -20,6 +20,7 @@
#include "BLI_utildefines.h"
#include "GPU_texture.h"
+#include "GPU_vertex_format.h"
#include "gpu_material_library.h"
#include "gpu_node_graph.h"
@@ -102,14 +103,6 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
input->source = GPU_SOURCE_TEX_TILED_MAPPING;
input->texture = link->texture;
break;
- case GPU_NODE_LINK_VOLUME_GRID:
- input->source = GPU_SOURCE_VOLUME_GRID;
- input->volume_grid = link->volume_grid;
- break;
- case GPU_NODE_LINK_VOLUME_GRID_TRANSFORM:
- input->source = GPU_SOURCE_VOLUME_GRID_TRANSFORM;
- input->volume_grid = link->volume_grid;
- break;
case GPU_NODE_LINK_ATTR:
input->source = GPU_SOURCE_ATTR;
input->attr = link->attr;
@@ -335,6 +328,45 @@ void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph)
/* Attributes and Textures */
+static char attr_prefix_get(CustomDataType type)
+{
+ switch (type) {
+ case CD_MTFACE:
+ return 'u';
+ case CD_TANGENT:
+ return 't';
+ case CD_MCOL:
+ case CD_PROP_BYTE_COLOR:
+ return 'c';
+ case CD_PROP_COLOR:
+ return 'c';
+ case CD_AUTO_FROM_NAME:
+ return 'a';
+ case CD_HAIRLENGTH:
+ return 'l';
+ default:
+ BLI_assert_msg(0, "GPUVertAttr Prefix type not found : This should not happen!");
+ return '\0';
+ }
+}
+
+static void attr_input_name(GPUMaterialAttribute *attr)
+{
+ /* NOTE: Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */
+ if (attr->type == CD_ORCO) {
+ /* OPTI: orco is computed from local positions, but only if no modifier is present. */
+ STRNCPY(attr->input_name, "orco");
+ }
+ else {
+ attr->input_name[0] = attr_prefix_get(attr->type);
+ attr->input_name[1] = '\0';
+ if (attr->name[0] != '\0') {
+ /* XXX FIXME: see notes in mesh_render_data_create() */
+ GPU_vertformat_safe_attr_name(attr->name, &attr->input_name[1], GPU_MAX_SAFE_ATTR_NAME);
+ }
+ }
+}
+
/** Add a new varying attribute of given type and name. Returns NULL if out of slots. */
static GPUMaterialAttribute *gpu_node_graph_add_attribute(GPUNodeGraph *graph,
CustomDataType type,
@@ -360,6 +392,7 @@ static GPUMaterialAttribute *gpu_node_graph_add_attribute(GPUNodeGraph *graph,
attr = MEM_callocN(sizeof(*attr), __func__);
attr->type = type;
STRNCPY(attr->name, name);
+ attr_input_name(attr);
attr->id = num_attributes;
BLI_addtail(&graph->attributes, attr);
}
@@ -443,35 +476,6 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph,
return tex;
}
-static GPUMaterialVolumeGrid *gpu_node_graph_add_volume_grid(GPUNodeGraph *graph,
- const char *name,
- eGPUVolumeDefaultValue default_value)
-{
- /* Find existing volume grid. */
- int num_grids = 0;
- GPUMaterialVolumeGrid *grid = graph->volume_grids.first;
- for (; grid; grid = grid->next) {
- if (STREQ(grid->name, name) && grid->default_value == default_value) {
- break;
- }
- num_grids++;
- }
-
- /* Add new requested volume grid. */
- if (grid == NULL) {
- grid = MEM_callocN(sizeof(*grid), __func__);
- grid->name = BLI_strdup(name);
- grid->default_value = default_value;
- BLI_snprintf(grid->sampler_name, sizeof(grid->sampler_name), "vsamp%d", num_grids);
- BLI_snprintf(grid->transform_name, sizeof(grid->transform_name), "vtfm%d", num_grids);
- BLI_addtail(&graph->volume_grids, grid);
- }
-
- grid->users++;
-
- return grid;
-}
-
/* Creating Inputs */
GPUNodeLink *GPU_attribute(GPUMaterial *mat, const CustomDataType type, const char *name)
@@ -496,6 +500,18 @@ GPUNodeLink *GPU_attribute(GPUMaterial *mat, const CustomDataType type, const ch
return link;
}
+GPUNodeLink *GPU_attribute_with_default(GPUMaterial *mat,
+ const CustomDataType type,
+ const char *name,
+ eGPUDefaultValue default_value)
+{
+ GPUNodeLink *link = GPU_attribute(mat, type, name);
+ if (link->link_type == GPU_NODE_LINK_ATTR) {
+ link->attr->default_value = default_value;
+ }
+ return link;
+}
+
GPUNodeLink *GPU_uniform_attribute(GPUMaterial *mat, const char *name, bool use_dupli)
{
GPUNodeGraph *graph = gpu_material_node_graph(mat);
@@ -586,39 +602,6 @@ GPUNodeLink *GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *ro
return link;
}
-GPUNodeLink *GPU_volume_grid(GPUMaterial *mat,
- const char *name,
- eGPUVolumeDefaultValue default_value)
-{
- /* NOTE: this could be optimized by automatically merging duplicate
- * lookups of the same attribute. */
- GPUNodeGraph *graph = gpu_material_node_graph(mat);
- GPUNodeLink *link = gpu_node_link_create();
- link->link_type = GPU_NODE_LINK_VOLUME_GRID;
- link->volume_grid = gpu_node_graph_add_volume_grid(graph, name, default_value);
-
- GPUNodeLink *transform_link = gpu_node_link_create();
- transform_link->link_type = GPU_NODE_LINK_VOLUME_GRID_TRANSFORM;
- transform_link->volume_grid = link->volume_grid;
- transform_link->volume_grid->users++;
-
- GPUNodeLink *cos_link = GPU_attribute(mat, CD_ORCO, "");
-
- /* Two special cases, where we adjust the output values of smoke grids to
- * bring the into standard range without having to modify the grid values. */
- if (STREQ(name, "color")) {
- GPU_link(mat, "node_attribute_volume_color", link, transform_link, cos_link, &link);
- }
- else if (STREQ(name, "temperature")) {
- GPU_link(mat, "node_attribute_volume_temperature", link, transform_link, cos_link, &link);
- }
- else {
- GPU_link(mat, "node_attribute_volume", link, transform_link, cos_link, &link);
- }
-
- return link;
-}
-
/* Creating Nodes */
bool GPU_link(GPUMaterial *mat, const char *name, ...)
@@ -767,9 +750,6 @@ static void gpu_inputs_free(ListBase *inputs)
else if (ELEM(input->source, GPU_SOURCE_TEX, GPU_SOURCE_TEX_TILED_MAPPING)) {
input->texture->users--;
}
- else if (ELEM(input->source, GPU_SOURCE_VOLUME_GRID, GPU_SOURCE_VOLUME_GRID_TRANSFORM)) {
- input->volume_grid->users--;
- }
if (input->link) {
gpu_node_link_free(input->link);
@@ -816,10 +796,6 @@ void gpu_node_graph_free(GPUNodeGraph *graph)
BLI_freelistN(&graph->material_functions);
gpu_node_graph_free_nodes(graph);
- LISTBASE_FOREACH (GPUMaterialVolumeGrid *, grid, &graph->volume_grids) {
- MEM_SAFE_FREE(grid->name);
- }
- BLI_freelistN(&graph->volume_grids);
BLI_freelistN(&graph->textures);
BLI_freelistN(&graph->attributes);
GPU_uniform_attr_list_free(&graph->uniform_attrs);
@@ -894,14 +870,6 @@ void gpu_node_graph_prune_unused(GPUNodeGraph *graph)
}
}
- for (GPUMaterialVolumeGrid *grid = graph->volume_grids.first, *next = NULL; grid; grid = next) {
- next = grid->next;
- if (grid->users == 0) {
- MEM_SAFE_FREE(grid->name);
- BLI_freelinkN(&graph->volume_grids, grid);
- }
- }
-
GPUUniformAttrList *uattrs = &graph->uniform_attrs;
LISTBASE_FOREACH_MUTABLE (GPUUniformAttr *, attr, &uattrs->list) {
diff --git a/source/blender/gpu/intern/gpu_node_graph.h b/source/blender/gpu/intern/gpu_node_graph.h
index 024119e1c24..ae472d5b7aa 100644
--- a/source/blender/gpu/intern/gpu_node_graph.h
+++ b/source/blender/gpu/intern/gpu_node_graph.h
@@ -34,8 +34,6 @@ typedef enum eGPUDataSource {
GPU_SOURCE_STRUCT,
GPU_SOURCE_TEX,
GPU_SOURCE_TEX_TILED_MAPPING,
- GPU_SOURCE_VOLUME_GRID,
- GPU_SOURCE_VOLUME_GRID_TRANSFORM,
GPU_SOURCE_FUNCTION_CALL,
} eGPUDataSource;
@@ -48,8 +46,6 @@ typedef enum {
GPU_NODE_LINK_IMAGE,
GPU_NODE_LINK_IMAGE_TILED,
GPU_NODE_LINK_IMAGE_TILED_MAPPING,
- GPU_NODE_LINK_VOLUME_GRID,
- GPU_NODE_LINK_VOLUME_GRID_TRANSFORM,
GPU_NODE_LINK_OUTPUT,
GPU_NODE_LINK_UNIFORM,
GPU_NODE_LINK_DIFFERENTIATE_FLOAT_FN,
@@ -90,8 +86,6 @@ struct GPUNodeLink {
const float *data;
/* GPU_NODE_LINK_COLORBAND */
struct GPUTexture **colorband;
- /* GPU_NODE_LINK_VOLUME_GRID */
- struct GPUMaterialVolumeGrid *volume_grid;
/* GPU_NODE_LINK_OUTPUT */
struct GPUOutput *output;
/* GPU_NODE_LINK_ATTR */
@@ -134,8 +128,6 @@ typedef struct GPUInput {
struct GPUMaterialAttribute *attr;
/* GPU_SOURCE_UNIFORM_ATTR */
struct GPUUniformAttr *uniform_attr;
- /* GPU_SOURCE_VOLUME_GRID | GPU_SOURCE_VOLUME_GRID_TRANSFORM */
- struct GPUMaterialVolumeGrid *volume_grid;
/* GPU_SOURCE_FUNCTION_CALL */
char function_call[64];
};
@@ -170,7 +162,6 @@ typedef struct GPUNodeGraph {
/* Requested attributes and textures. */
ListBase attributes;
ListBase textures;
- ListBase volume_grids;
/* The list of uniform attributes. */
GPUUniformAttrList uniform_attrs;
diff --git a/source/blender/gpu/intern/gpu_shader_builtin.c b/source/blender/gpu/intern/gpu_shader_builtin.c
index dfedb64ce61..1958ecedb28 100644
--- a/source/blender/gpu/intern/gpu_shader_builtin.c
+++ b/source/blender/gpu/intern/gpu_shader_builtin.c
@@ -402,19 +402,6 @@ GPUShader *GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
return GPU_shader_get_builtin_shader_with_config(shader, GPU_SHADER_CFG_DEFAULT);
}
-void GPU_shader_get_builtin_shader_code(eGPUBuiltinShader shader,
- const char **r_vert,
- const char **r_frag,
- const char **r_geom,
- const char **r_defines)
-{
- const GPUShaderStages *stages = &builtin_shader_stages[shader];
- *r_vert = stages->vert;
- *r_frag = stages->frag;
- *r_geom = stages->geom;
- *r_defines = stages->defs;
-}
-
void GPU_shader_free_builtin_shaders(void)
{
for (int i = 0; i < GPU_SHADER_CFG_LEN; i++) {
diff --git a/source/blender/gpu/intern/gpu_shader_create_info.hh b/source/blender/gpu/intern/gpu_shader_create_info.hh
index 3ab96d0d84a..7c827e237eb 100644
--- a/source/blender/gpu/intern/gpu_shader_create_info.hh
+++ b/source/blender/gpu/intern/gpu_shader_create_info.hh
@@ -627,7 +627,9 @@ struct ShaderCreateInfo {
Resource res(Resource::BindType::SAMPLER, slot);
res.sampler.type = type;
res.sampler.name = name;
- res.sampler.sampler = sampler;
+ /* Produces ASAN errors for the moment. */
+ // res.sampler.sampler = sampler;
+ UNUSED_VARS(sampler);
((freq == Frequency::PASS) ? pass_resources_ : batch_resources_).append(res);
interface_names_size_ += name.size() + 1;
return *(Self *)this;