Blender V5.3
gpu_py_shader_create_info.cc File Reference
#include <Python.h>
#include "BLI_utildefines.hh"
#include "GPU_shader.hh"
#include "intern/gpu_shader_create_info.hh"
#include "../generic/py_capi_utils.hh"
#include "../generic/python_compat.hh"
#include "gpu_py_shader.hh"
#include "gpu_py_texture.hh"

Go to the source code of this file.

Classes

struct  blender::ShaderCreateInfo
 Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correctly provided, this is all that is needed to create and compile a #gpu::Shader. More...
struct  blender::StageInterfaceInfo

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define USE_PYGPU_SHADER_INFO_IMAGE_METHOD
#define PYDOC_QUALIFIERS_LITERAL   "Literal['NO_RESTRICT', 'READ', 'WRITE']"
#define PYDOC_TYPE_LITERAL
#define PYDOC_IMAGE_TYPES_LITERAL
#define PYDOC_TEX_FORMAT_LITERAL
#define VULKAN_LIMIT   128

Enumerations

enum class  blender::DepthWrite
enum class  blender::DualBlend
enum class  blender::Frequency
enum class  blender::ImageType
enum class  blender::Type
enum class  blender::Qualifier

Functions

GPUStageInterfaceInfo Type
static PyObject * blender::pygpu_interface_info__tp_new (PyTypeObject *, PyObject *args, PyObject *kwds)
static int blender::pygpu_interface_info__tp_traverse (PyObject *self, visitproc visit, void *arg)
static int blender::pygpu_interface_info__tp_clear (PyObject *self)
static void blender::pygpu_interface_info__tp_dealloc (PyObject *self)
 blender::PyDoc_STRVAR (pygpu_interface_info__tp_doc, ".. class:: GPUStageInterfaceInfo\n" "\n" " List of varyings between shader stages.\n" "\n" " .. method:: __init__(name)\n" "\n" " :param name: Name of the interface block.\n" " :type name: str\n")
GPUShaderCreateInfo Initialization
static PyObject * blender::pygpu_shader_info__tp_new (PyTypeObject *, PyObject *args, PyObject *kwds)
static int blender::pygpu_shader_info__tp_traverse (PyObject *self, visitproc visit, void *arg)
static int blender::pygpu_shader_info__tp_clear (PyObject *self)
static void blender::pygpu_shader_info__tp_dealloc (PyObject *self)
 blender::PyDoc_STRVAR (pygpu_shader_info__tp_doc, ".. class:: GPUShaderCreateInfo()\n" "\n" " Stores and describes types and variables that are used in shader sources.\n")
Public API
PyObject * blender::BPyGPUStageInterfaceInfo_CreatePyObject (GPUStageInterfaceInfo *interface)
PyObject * blender::BPyGPUShaderCreateInfo_CreatePyObject (GPUShaderCreateInfo *info)

Variables

static const PyC_FlagSet blender::pygpu_qualifiers []
static const PyC_StringEnumItems blender::pygpu_imagetype_items []
static const PyC_StringEnumItems blender::pygpu_dualblend_items []
static const PyC_StringEnumItems blender::pygpu_depth_write_items []
const PyC_StringEnumItems blender::pygpu_tex_format_items []

GPUStageInterfaceInfo Methods

static PyMethodDef blender::pygpu_interface_info__tp_methods []
static bool blender::pygpu_interface_info_get_args (BPyGPUStageInterfaceInfo *self, PyObject *args, const char *format, Type *r_type, const char **r_name)
 blender::PyDoc_STRVAR (pygpu_interface_info_smooth_doc, ".. method:: smooth(type, name)\n" "\n" " Add an attribute with qualifier of type *smooth* to the interface block.\n" "\n" " :param type: The data type of the attribute.\n" " :type type: " PYDOC_TYPE_LITERAL "\n" " :param name: name of the attribute.\n" " :type name: str\n")
static PyObject * blender::pygpu_interface_info_smooth (BPyGPUStageInterfaceInfo *self, PyObject *args)
 blender::PyDoc_STRVAR (pygpu_interface_info_flat_doc, ".. method:: flat(type, name)\n" "\n" " Add an attribute with qualifier of type ``flat`` to the interface block.\n" "\n" " :param type: The data type of the attribute.\n" " :type type: " PYDOC_TYPE_LITERAL "\n" " :param name: name of the attribute.\n" " :type name: str\n")
static PyObject * blender::pygpu_interface_info_flat (BPyGPUStageInterfaceInfo *self, PyObject *args)
 blender::PyDoc_STRVAR (pygpu_interface_info_no_perspective_doc, ".. method:: no_perspective(type, name)\n" "\n" " Add an attribute with qualifier of type ``no_perspective`` to the interface block.\n" "\n" " :param type: The data type of the attribute.\n" " :type type: " PYDOC_TYPE_LITERAL "\n" " :param name: name of the attribute.\n" " :type name: str\n")
static PyObject * blender::pygpu_interface_info_no_perspective (BPyGPUStageInterfaceInfo *self, PyObject *args)

GPUStageInterfaceInfo Getters and Setters

static PyGetSetDef blender::pygpu_interface_info__tp_getseters []
 blender::PyDoc_STRVAR (pygpu_interface_info_name_doc, "Name of the interface block.\n" "\n" ":type: str\n")
static PyObject * blender::pygpu_interface_info_name_get (BPyGPUStageInterfaceInfo *self, void *)

GPUShaderCreateInfo Methods

static PyMethodDef blender::pygpu_shader_info__tp_methods []
 blender::PyDoc_STRVAR (pygpu_shader_info_vertex_in_doc, ".. method:: vertex_in(slot, type, name)\n" "\n" " Add a vertex shader input attribute.\n" "\n" " :param slot: The attribute index.\n" " :type slot: int\n" " :param type: The data type of the attribute.\n" " :type type: " PYDOC_TYPE_LITERAL "\n" " :param name: name of the attribute.\n" " :type name: str\n")
static PyObject * blender::pygpu_shader_info_vertex_in (BPyGPUShaderCreateInfo *self, PyObject *args)
 blender::PyDoc_STRVAR (pygpu_shader_info_vertex_out_doc, ".. method:: vertex_out(interface)\n" "\n" " Add a vertex shader output interface block.\n" "\n" " :param interface: Object describing the block.\n" " :type interface: :class:`gpu.types.GPUStageInterfaceInfo`\n")
static PyObject * blender::pygpu_shader_info_vertex_out (BPyGPUShaderCreateInfo *self, BPyGPUStageInterfaceInfo *o)
 blender::PyDoc_STRVAR (pygpu_shader_info_fragment_out_doc, ".. method:: fragment_out(slot, type, name, *, blend='NONE')\n" "\n" " Specify a fragment output corresponding to a framebuffer target slot.\n" "\n" " :param slot: The attribute index.\n" " :type slot: int\n" " :param type: The data type of the output.\n" " :type type: " PYDOC_TYPE_LITERAL "\n" " :param name: Name of the attribute.\n" " :type name: str\n" " :param blend: Dual Source Blending Index.\n" " :type blend: Literal['NONE', 'SRC_0', 'SRC_1']\n")
static PyObject * blender::pygpu_shader_info_fragment_out (BPyGPUShaderCreateInfo *self, PyObject *args, PyObject *kwds)
 blender::PyDoc_STRVAR (pygpu_shader_info_depth_write_doc, ".. method:: depth_write(value)\n" "\n" " Specify a depth write behavior when modifying gl_FragDepth.\n" "\n" " There is a common optimization for GPUs that relies on an early depth\n" " test to be run before the fragment shader so that the shader evaluation\n" " can be skipped if the fragment ends up being discarded because it is occluded.\n" "\n" " This optimization does not affect the final rendering, and is typically\n" " possible when the fragment does not change the depth programmatically.\n" " There is, however, a class of operations on the depth in the shader which\n" " could still be performed while allowing the early depth test to operate.\n" "\n" " This function alters the behavior of the optimization to allow those operations\n" " to be performed.\n" "\n" " :param value: Depth write value.\n" " :UNCHANGED: disables depth write in a fragment shader and execution of the " "fragments can be optimized away.\n" " :ANY: enables depth write in a fragment shader for any fragments\n" " :GREATER: enables depth write in a fragment shader for depth values that " "are greater than the depth value in the output buffer.\n" " :LESS: enables depth write in a fragment shader for depth values that " "are less than the depth value in the output buffer.\n" " :type value: Literal['UNCHANGED', 'ANY', 'GREATER', 'LESS']\n")
static PyObject * blender::pygpu_shader_info_depth_write (BPyGPUShaderCreateInfo *self, PyObject *args)
 blender::PyDoc_STRVAR (pygpu_shader_info_uniform_buf_doc, ".. method:: uniform_buf(slot, type_name, name)\n" "\n" " Specify a uniform variable whose type can be one of those declared in " ":meth:`gpu.types.GPUShaderCreateInfo.typedef_source`.\n" "\n" " :param slot: The uniform variable index.\n" " :type slot: int\n" " :param type_name: Name of the data type. " "It can be a struct type defined in the source passed through the " ":meth:`gpu.types.GPUShaderCreateInfo.typedef_source`.\n" " :type type_name: str\n" " :param name: The uniform variable name.\n" " :type name: str\n")
static PyObject * blender::pygpu_shader_info_uniform_buf (BPyGPUShaderCreateInfo *self, PyObject *args)
 blender::PyDoc_STRVAR (pygpu_shader_info_storage_buf_doc, ".. method:: storage_buf(slot, type_name, name, *, qualifiers={'READ', 'WRITE'})\n" "\n" " Specify a storage buffer variable whose type can be one of those declared in " ":meth:`gpu.types.GPUShaderCreateInfo.typedef_source`.\n" "\n" " :param slot: The storage buffer variable index.\n" " :type slot: int\n" " :param type_name: Name of the data type. " "It can be a struct type defined in the source passed through the " ":meth:`gpu.types.GPUShaderCreateInfo.typedef_source`.\n" " :type type_name: str\n" " :param name: The storage buffer variable name.\n" " :type name: str\n" " :param qualifiers: Set containing values that describe how the storage buffer is to be " "read or written.\n" " :type qualifiers: set[" PYDOC_QUALIFIERS_LITERAL "]\n")
static PyObject * blender::pygpu_shader_info_storage_buf (BPyGPUShaderCreateInfo *self, PyObject *args, PyObject *kwds)
 blender::PyDoc_STRVAR (pygpu_shader_info_image_doc, ".. method:: image(slot, format, type, name, *, qualifiers={'NO_RESTRICT'})\n" "\n" " Specify an image resource used for arbitrary load and store operations.\n" "\n" " :param slot: The image resource index.\n" " :type slot: int\n" " :param format: The GPUTexture format that is passed to the shader.\n" " :type format: " PYDOC_TEX_FORMAT_LITERAL "\n" " :param type: The data type describing how the image is to be read in the shader.\n" " :type type: " PYDOC_IMAGE_TYPES_LITERAL "\n" " :param name: The image resource name.\n" " :type name: str\n" " :param qualifiers: Set containing values that describe how the image resource is to be " "read or written.\n" " :type qualifiers: set[" PYDOC_QUALIFIERS_LITERAL "]\n")
static PyObject * blender::pygpu_shader_info_image (BPyGPUShaderCreateInfo *self, PyObject *args, PyObject *kwds)
 blender::PyDoc_STRVAR (pygpu_shader_info_sampler_doc, ".. method:: sampler(slot, type, name)\n" "\n" " Specify an image texture sampler.\n" "\n" " :param slot: The image texture sampler index.\n" " :type slot: int\n" " :param type: The data type describing the format of each sampler unit.\n" " :type type: " PYDOC_IMAGE_TYPES_LITERAL "\n" " :param name: The image texture sampler name.\n" " :type name: str\n")
static PyObject * blender::pygpu_shader_info_sampler (BPyGPUShaderCreateInfo *self, PyObject *args)
static int blender::constant_type_size (Type type)
static int blender::constants_calc_size (ShaderCreateInfo *info)
 blender::PyDoc_STRVAR (pygpu_shader_info_push_constant_doc, ".. method:: push_constant(type, name, size=0)\n" "\n" " Specify a global access constant.\n" "\n" " :param type: The data type of the constant.\n" " :type type: " PYDOC_TYPE_LITERAL "\n" " :param name: Name of the constant.\n" " :type name: str\n" " :param size: If not zero, indicates that the constant is an array " "with the specified size.\n" " :type size: int\n")
static PyObject * blender::pygpu_shader_info_push_constant (BPyGPUShaderCreateInfo *self, PyObject *args, PyObject *kwds)
 blender::PyDoc_STRVAR (pygpu_shader_info_vertex_source_doc, ".. method:: vertex_source(source)\n" "\n" " Vertex shader source code written in GLSL.\n" "\n" " Example:\n" "\n" " .. code-block:: python\n" "\n" " \"void main() {gl_Position = vec4(pos, 1.0);}\"\n" "\n" " :param source: The vertex shader source code.\n" " :type source: str\n" "\n" " .. seealso:: `GLSL Cross Compilation " "<https://developer.blender.org/docs/features/gpu/glsl_cross_compilation/>`__\n")
static PyObject * blender::pygpu_shader_info_vertex_source (BPyGPUShaderCreateInfo *self, PyObject *o)
 blender::PyDoc_STRVAR (pygpu_shader_info_compute_source_doc, ".. method:: compute_source(source)\n" "\n" " compute shader source code written in GLSL.\n" "\n" " Example:\n" "\n" " .. code-block:: python\n" "\n" " \"\"\"void main() {\n" " int2 index = int2(gl_GlobalInvocationID.xy);\n" " vec4 color = vec4(0.0, 0.0, 0.0, 1.0);\n" " imageStore(img_output, index, color);\n" " }\"\"\"\n" "\n" " :param source: The compute shader source code.\n" " :type source: str\n" "\n" " .. seealso:: `GLSL Cross Compilation " "<https://developer.blender.org/docs/features/gpu/glsl_cross_compilation/>`__\n")
static PyObject * blender::pygpu_shader_info_compute_source (BPyGPUShaderCreateInfo *self, PyObject *o)
 blender::PyDoc_STRVAR (pygpu_shader_info_fragment_source_doc, ".. method:: fragment_source(source)\n" "\n" " Fragment shader source code written in GLSL.\n" "\n" " Example:\n" "\n" " .. code-block:: python\n" "\n" " \"void main() {fragColor = vec4(0.0, 0.0, 0.0, 1.0);}\"\n" "\n" " :param source: The fragment shader source code.\n" " :type source: str\n" "\n" " .. seealso:: `GLSL Cross Compilation " "<https://developer.blender.org/docs/features/gpu/glsl_cross_compilation/>`__\n")
static PyObject * blender::pygpu_shader_info_fragment_source (BPyGPUShaderCreateInfo *self, PyObject *o)
 blender::PyDoc_STRVAR (pygpu_shader_info_typedef_source_doc, ".. method:: typedef_source(source)\n" "\n" " Source code included before resource declaration. " "Useful for defining structs used by Uniform Buffers.\n" "\n" " Example:\n" "\n" " .. code-block:: python\n" "\n" " \"struct MyType {int foo; float bar;};\"\n" "\n" " :param source: The source code defining types.\n" " :type source: str\n")
static PyObject * blender::pygpu_shader_info_typedef_source (BPyGPUShaderCreateInfo *self, PyObject *o)
 blender::PyDoc_STRVAR (pygpu_shader_info_define_doc, ".. method:: define(name, value)\n" "\n" " Add a preprocessing define directive. In GLSL it would be something like:\n" "\n" " .. code-block:: glsl\n" "\n" " #define name value\n" "\n" " :param name: Token name.\n" " :type name: str\n" " :param value: Text that replaces token occurrences.\n" " :type value: str\n")
static PyObject * blender::pygpu_shader_info_define (BPyGPUShaderCreateInfo *self, PyObject *args)
 blender::PyDoc_STRVAR (pygpu_shader_info_local_group_size_doc, ".. method:: local_group_size(x, y=1, z=1)\n" "\n" " Specify the local group size for compute shaders.\n" "\n" " :param x: The local group size in the x dimension.\n" " :type x: int\n" " :param y: The local group size in the y dimension. Optional. Defaults to 1.\n" " :type y: int\n" " :param z: The local group size in the z dimension. Optional. Defaults to 1.\n" " :type z: int\n")
static PyObject * blender::pygpu_shader_info_local_group_size (BPyGPUShaderCreateInfo *self, PyObject *args)

Detailed Description

  • Use bpygpu_ for local API.
  • Use BPyGPU for public API.

Definition in file gpu_py_shader_create_info.cc.

Macro Definition Documentation

◆ PYDOC_IMAGE_TYPES_LITERAL

#define PYDOC_IMAGE_TYPES_LITERAL

Definition at line 85 of file gpu_py_shader_create_info.cc.

Referenced by blender::PyDoc_STRVAR(), and blender::PyDoc_STRVAR().

◆ PYDOC_QUALIFIERS_LITERAL

#define PYDOC_QUALIFIERS_LITERAL   "Literal['NO_RESTRICT', 'READ', 'WRITE']"

Definition at line 40 of file gpu_py_shader_create_info.cc.

Referenced by blender::PyDoc_STRVAR(), and blender::PyDoc_STRVAR().

◆ PYDOC_TEX_FORMAT_LITERAL

#define PYDOC_TEX_FORMAT_LITERAL

Definition at line 176 of file gpu_py_shader_create_info.cc.

Referenced by blender::PyDoc_STRVAR(), and blender::PyDoc_STRVAR().

◆ PYDOC_TYPE_LITERAL

#define PYDOC_TYPE_LITERAL
Value:
"Literal[" \
"'FLOAT', " \
"'VEC2', " \
"'VEC3', " \
"'VEC4', " \
"'MAT3', " \
"'MAT4', " \
"'UINT', " \
"'UVEC2', " \
"'UVEC3', " \
"'UVEC4', " \
"'INT', " \
"'IVEC2', " \
"'IVEC3', " \
"'IVEC4', " \
"'BOOL']"

Definition at line 49 of file gpu_py_shader_create_info.cc.

Referenced by blender::PyDoc_STRVAR(), blender::PyDoc_STRVAR(), blender::PyDoc_STRVAR(), blender::PyDoc_STRVAR(), blender::PyDoc_STRVAR(), and blender::PyDoc_STRVAR().

◆ USE_PYGPU_SHADER_INFO_IMAGE_METHOD

#define USE_PYGPU_SHADER_INFO_IMAGE_METHOD

Definition at line 27 of file gpu_py_shader_create_info.cc.

◆ VULKAN_LIMIT

#define VULKAN_LIMIT   128