diff options
author | Jeroen Bakker <jbakker> | 2022-01-17 16:32:03 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-01-17 16:32:28 +0300 |
commit | 8fb2ff458ba579dba08bfdf57d043ad158b5db07 (patch) | |
tree | e6324c08c69de3e8ed34c1f85d0b2982fa1d38ed /source/blender/gpu/intern/gpu_shader_builder_stubs.cc | |
parent | 08822801acf648d23791fa308ec8c1c26f86963e (diff) |
GPUShaderCreateInfo for interface abstraction
This is a first part of the Shader Create Info system could be.
A shader create info provides a way to define shader structure, resources
and interfaces. This makes for a quick way to provide backend agnostic
binding informations while also making shader variations easy to declare.
- Clear source input (only one file). Cleans up the GPU api since we can create a
shader from one descriptor
- Resources and interfaces are generated by the backend (much simpler than parsing).
- Bindings are explicit from position in the array.
- GPUShaderInterface becomes a trivial translation of enums and string copy.
- No external dependency to third party lib.
- Cleaner code, less fragmentation of resources in several libs.
- Easy to modify / extend at runtime.
- no parser involve, very easy to code.
- Does not hold any data, can be static and kept on disc.
- Could hold precompiled bytecode for static shaders.
This also includes a new global dependency system.
GLSL shaders can include other sources by using #pragma BLENDER_REQUIRE(...).
This patch already migrated several builtin shaders. Other shaders should be migrated
one at a time, and could be done inside master.
There is a new compile directive `WITH_GPU_SHADER_BUILDER` this is an optional
directive for linting shaders to increase turn around time.
What is remaining:
- pyGPU API {T94975}
- Migration of other shaders. This could be a community effort.
Reviewed By: jbakker
Maniphest Tasks: T94975
Differential Revision: https://developer.blender.org/D13360
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader_builder_stubs.cc')
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_builder_stubs.cc | 258 |
1 files changed, 258 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_shader_builder_stubs.cc b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc new file mode 100644 index 00000000000..40e54ab4394 --- /dev/null +++ b/source/blender/gpu/intern/gpu_shader_builder_stubs.cc @@ -0,0 +1,258 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2021 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + * + * Stubs to reduce linking time for shader_builder. + */ + +#include "BLI_utildefines.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +#include "BKE_customdata.h" +#include "BKE_global.h" +#include "BKE_material.h" +#include "BKE_mesh.h" +#include "BKE_node.h" +#include "BKE_paint.h" +#include "BKE_pbvh.h" +#include "BKE_subdiv_ccg.h" + +#include "DNA_userdef_types.h" + +#include "DRW_engine.h" + +#include "bmesh.h" + +#include "UI_resources.h" + +extern "C" { + +Global G; +UserDef U; + +/* -------------------------------------------------------------------- */ +/** \name Stubs of BLI_imbuf_types.h + * \{ */ + +void IMB_freeImBuf(ImBuf *UNUSED(ibuf)) +{ + BLI_assert_unreachable(); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of UI_resources.h + * \{ */ + +void UI_GetThemeColor4fv(int UNUSED(colorid), float UNUSED(col[4])) +{ + BLI_assert_unreachable(); +} + +void UI_GetThemeColor3fv(int UNUSED(colorid), float UNUSED(col[3])) +{ + BLI_assert_unreachable(); +} + +void UI_GetThemeColorShade4fv(int UNUSED(colorid), int UNUSED(offset), float UNUSED(col[4])) +{ + BLI_assert_unreachable(); +} + +void UI_GetThemeColorShadeAlpha4fv(int UNUSED(colorid), + int UNUSED(coloffset), + int UNUSED(alphaoffset), + float UNUSED(col[4])) +{ + BLI_assert_unreachable(); +} +void UI_GetThemeColorBlendShade4fv(int UNUSED(colorid1), + int UNUSED(colorid2), + float UNUSED(fac), + int UNUSED(offset), + float UNUSED(col[4])) +{ + BLI_assert_unreachable(); +} + +void UI_GetThemeColorBlend3ubv(int UNUSED(colorid1), + int UNUSED(colorid2), + float UNUSED(fac), + unsigned char UNUSED(col[3])) +{ + BLI_assert_unreachable(); +} + +void UI_GetThemeColorShadeAlpha4ubv(int UNUSED(colorid), + int UNUSED(coloffset), + int UNUSED(alphaoffset), + unsigned char UNUSED(col[4])) +{ + BLI_assert_unreachable(); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of BKE_paint.h + * \{ */ +bool paint_is_face_hidden(const struct MLoopTri *UNUSED(lt), + const struct MVert *UNUSED(mvert), + const struct MLoop *UNUSED(mloop)) +{ + BLI_assert_unreachable(); + return false; +} + +void BKE_paint_face_set_overlay_color_get(const int UNUSED(face_set), + const int UNUSED(seed), + uchar UNUSED(r_color[4])) +{ + BLI_assert_unreachable(); +} + +bool paint_is_grid_face_hidden(const unsigned int *UNUSED(grid_hidden), + int UNUSED(gridsize), + int UNUSED(x), + int UNUSED(y)) +{ + BLI_assert_unreachable(); + return false; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of BKE_mesh.h + * \{ */ +void BKE_mesh_calc_poly_normal(const struct MPoly *UNUSED(mpoly), + const struct MLoop *UNUSED(loopstart), + const struct MVert *UNUSED(mvarray), + float UNUSED(r_no[3])) +{ + BLI_assert_unreachable(); +} + +void BKE_mesh_looptri_get_real_edges(const struct Mesh *UNUSED(mesh), + const struct MLoopTri *UNUSED(looptri), + int UNUSED(r_edges[3])) +{ + BLI_assert_unreachable(); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of BKE_material.h + * \{ */ + +void BKE_material_defaults_free_gpu(void) +{ + /* This function is reachable via GPU_exit. */ +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of BKE_customdata.h + * \{ */ + +int CustomData_get_offset(const struct CustomData *UNUSED(data), int UNUSED(type)) +{ + BLI_assert_unreachable(); + return 0; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of BKE_pbvh.h + * \{ */ + +int BKE_pbvh_count_grid_quads(BLI_bitmap **UNUSED(grid_hidden), + const int *UNUSED(grid_indices), + int UNUSED(totgrid), + int UNUSED(gridsize)) +{ + BLI_assert_unreachable(); + return 0; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of BKE_subdiv_ccg.h + * \{ */ +int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG *UNUSED(subdiv_ccg), + const int UNUSED(grid_index)) +{ + BLI_assert_unreachable(); + return 0; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of BKE_node.h + * \{ */ +void ntreeGPUMaterialNodes(struct bNodeTree *UNUSED(localtree), + struct GPUMaterial *UNUSED(mat), + bool *UNUSED(has_surface_output), + bool *UNUSED(has_volume_output)) +{ + BLI_assert_unreachable(); +} + +struct bNodeTree *ntreeLocalize(struct bNodeTree *UNUSED(ntree)) +{ + BLI_assert_unreachable(); + return nullptr; +} + +void ntreeFreeLocalTree(struct bNodeTree *UNUSED(ntree)) +{ + BLI_assert_unreachable(); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of bmesh.h + * \{ */ +void BM_face_as_array_vert_tri(BMFace *UNUSED(f), BMVert *UNUSED(r_verts[3])) +{ + BLI_assert_unreachable(); +} +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Stubs of DRW_engine.h + * \{ */ +void DRW_deferred_shader_remove(struct GPUMaterial *UNUSED(mat)) +{ + BLI_assert_unreachable(); +} + +/** \} */ +} |