diff options
author | Germano Cavalcante <mano-wii> | 2022-09-01 14:21:10 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2022-09-01 14:25:55 +0300 |
commit | 6269d66da29ae000f214e775ee54dfc71623e642 (patch) | |
tree | cbf2fb0f29c3d770ede527e844a1e749f78c5522 /source/blender/gpu/intern/gpu_shader_interface.hh | |
parent | 05fe7ca5af93208e56e3b120fa9caf157f43fc75 (diff) |
PyGPU: GPUShader: implementation of 'attrs_info_get' method
With the new `attrs_info_get` method, we can get information about
the attributes used in a `GPUShader` and thus have more freedom in the
automatic creation of `GPUVertFormat`s
Reviewed By: fclem, campbellbarton
Differential Revision: https://developer.blender.org/D15764
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader_interface.hh')
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_interface.hh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_shader_interface.hh b/source/blender/gpu/intern/gpu_shader_interface.hh index 812244c9b3a..41e06569bdc 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.hh +++ b/source/blender/gpu/intern/gpu_shader_interface.hh @@ -18,6 +18,7 @@ #include "BLI_utildefines.h" #include "GPU_shader.h" +#include "GPU_vertex_format.h" /* GPU_VERT_ATTR_MAX_LEN */ #include "gpu_shader_create_info.hh" namespace blender::gpu { @@ -58,6 +59,13 @@ class ShaderInterface { int32_t builtin_blocks_[GPU_NUM_UNIFORM_BLOCKS]; int32_t builtin_buffers_[GPU_NUM_STORAGE_BUFFERS]; + /** + * Currently only used for `GPU_shader_get_attribute_info`. + * This utility is useful for automatic creation of `GPUVertFormat` in Python. + * Use `ShaderInput::location` to identify the `Type`. + */ + uint8_t attr_types_[GPU_VERT_ATTR_MAX_LEN]; + public: ShaderInterface(); ShaderInterface(const shader::ShaderCreateInfo &info); @@ -69,6 +77,10 @@ class ShaderInterface { { return input_lookup(inputs_, attr_len_, name); } + inline const ShaderInput *attr_get(const int binding) const + { + return input_lookup(inputs_, attr_len_, binding); + } inline const ShaderInput *ubo_get(const char *name) const { |