74 pygpu_state_blend_set_doc,
75 ".. function:: blend_set(mode)\n"
77 " Defines the fixed pipeline blending equation.\n"
79 " :arg mode: The type of blend mode.\n"
81 " * ``NONE`` No blending.\n"
82 " * ``ALPHA`` The original color channels are interpolated according to the alpha "
84 " * ``ALPHA_PREMULT`` The original color channels are interpolated according to the "
85 "alpha value with the new colors pre-multiplied by this value.\n"
86 " * ``ADDITIVE`` The original color channels are added by the corresponding ones.\n"
87 " * ``ADDITIVE_PREMULT`` The original color channels are added by the corresponding ones "
88 "that are pre-multiplied by the alpha value.\n"
89 " * ``MULTIPLY`` The original color channels are multiplied by the corresponding ones.\n"
90 " * ``SUBTRACT`` The original color channels are subtracted by the corresponding ones.\n"
91 " * ``INVERT`` The original color channels are replaced by its complementary color.\n"
95 " :type mode: str\n");
110 pygpu_state_blend_get_doc,
111 ".. function:: blend_get()\n"
113 " Current blending equation.\n"
125 pygpu_state_clip_distances_set_doc,
126 ".. function:: clip_distances_set(distances_enabled)\n"
128 " Sets the number of `gl_ClipDistance` planes used for clip geometry.\n"
130 " :arg distances_enabled: Number of clip distances enabled.\n"
131 " :type distances_enabled: int\n");
136 int distances_enabled =
int(PyLong_AsUnsignedLong(value));
137 if (distances_enabled == -1) {
141 if (distances_enabled > 6) {
142 PyErr_SetString(PyExc_ValueError,
"too many distances enabled, max is 6");
151 pygpu_state_depth_test_set_doc,
152 ".. function:: depth_test_set(mode)\n"
154 " Defines the depth_test equation.\n"
156 " :arg mode: The depth test equation name.\n"
157 " Possible values are `NONE`, `ALWAYS`, `LESS`, `LESS_EQUAL`, `EQUAL`, "
158 "`GREATER` and `GREATER_EQUAL`.\n"
159 " :type mode: str\n");
174 pygpu_state_depth_test_get_doc,
175 ".. function:: depth_test_get()\n"
177 " Current depth_test equation.\n"
189 pygpu_state_depth_mask_set_doc,
190 ".. function:: depth_mask_set(value)\n"
192 " Write to depth component.\n"
194 " :arg value: True for writing to the depth component.\n"
195 " :type near: bool\n");
210 pygpu_state_depth_mask_get_doc,
211 ".. function:: depth_mask_get()\n"
213 " Writing status in the depth component.\n");
223 pygpu_state_viewport_set_doc,
224 ".. function:: viewport_set(x, y, xsize, ysize)\n"
226 " Specifies the viewport of the active framebuffer.\n"
227 " Note: The viewport state is not saved upon framebuffer rebind.\n"
229 " :arg x, y: lower left corner of the viewport_set rectangle, in pixels.\n"
231 " :arg xsize, ysize: width and height of the viewport_set.\n"
232 " :type xsize, ysize: int\n");
237 int x,
y, xsize, ysize;
238 if (!PyArg_ParseTuple(args,
"iiii:viewport_set", &x, &y, &xsize, &ysize)) {
248 pygpu_state_viewport_get_doc,
249 ".. function:: viewport_get()\n"
251 " Viewport of the active framebuffer.\n");
259 PyObject *
ret = PyTuple_New(4);
261 PyLong_FromLong(viewport[0]),
262 PyLong_FromLong(viewport[1]),
263 PyLong_FromLong(viewport[2]),
264 PyLong_FromLong(viewport[3]));
270 pygpu_state_scissor_set_doc,
271 ".. function:: scissor_set(x, y, xsize, ysize)\n"
273 " Specifies the scissor area of the active framebuffer.\n"
274 " Note: The scissor state is not saved upon framebuffer rebind.\n"
276 " :arg x, y: lower left corner of the scissor rectangle, in pixels.\n"
278 " :arg xsize, ysize: width and height of the scissor rectangle.\n"
279 " :type xsize, ysize: int\n");
284 int x,
y, xsize, ysize;
285 if (!PyArg_ParseTuple(args,
"iiii:scissor_set", &x, &y, &xsize, &ysize)) {
295 pygpu_state_scissor_get_doc,
296 ".. function:: scissor_get()\n"
298 " Retrieve the scissors of the active framebuffer.\n"
299 " Note: Only valid between 'scissor_set' and a framebuffer rebind.\n"
301 " :return: The scissor of the active framebuffer as a tuple\n"
302 " (x, y, xsize, ysize).\n"
303 " x, y: lower left corner of the scissor rectangle, in pixels.\n"
304 " xsize, ysize: width and height of the scissor rectangle.\n"
305 " :rtype: tuple[int, int, int, int]\n");
313 PyObject *
ret = PyTuple_New(4);
315 PyLong_FromLong(scissor[0]),
316 PyLong_FromLong(scissor[1]),
317 PyLong_FromLong(scissor[2]),
318 PyLong_FromLong(scissor[3]));
324 pygpu_state_scissor_test_set_doc,
325 ".. function:: scissor_test_set(enable)\n"
327 " Enable/disable scissor testing on the active framebuffer.\n"
330 " True - enable scissor testing.\n"
331 " False - disable scissor testing.\n"
332 " :type enable: bool\n");
348 pygpu_state_line_width_set_doc,
349 ".. function:: line_width_set(width)\n"
351 " Specify the width of rasterized lines.\n"
353 " :arg size: New width.\n"
354 " :type mode: float\n");
359 float width =
float(PyFloat_AsDouble(value));
360 if (PyErr_Occurred()) {
370 pygpu_state_line_width_get_doc,
371 ".. function:: line_width_get()\n"
373 " Current width of rasterized lines.\n");
379 return PyFloat_FromDouble(
double(width));
384 pygpu_state_point_size_set_doc,
385 ".. function:: point_size_set(size)\n"
387 " Specify the diameter of rasterized points.\n"
389 " :arg size: New diameter.\n"
390 " :type mode: float\n");
395 float size =
float(PyFloat_AsDouble(value));
396 if (PyErr_Occurred()) {
406 pygpu_state_color_mask_set_doc,
407 ".. function:: color_mask_set(r, g, b, a)\n"
409 " Enable or disable writing of frame buffer color components.\n"
411 " :arg r, g, b, a: components red, green, blue, and alpha.\n"
412 " :type r, g, b, a: bool\n");
418 if (!PyArg_ParseTuple(args,
"pppp:color_mask_set", &r, &g, &
b, &a)) {
428 pygpu_state_face_culling_set_doc,
429 ".. function:: face_culling_set(culling)\n"
431 " Specify whether none, front-facing or back-facing facets can be culled.\n"
433 " :arg mode: `NONE`, `FRONT` or `BACK`.\n"
434 " :type mode: str\n");
450 pygpu_state_front_facing_set_doc,
451 ".. function:: front_facing_set(invert)\n"
453 " Specifies the orientation of front-facing polygons.\n"
455 " :arg invert: True for clockwise polygons as front-facing.\n"
456 " :type mode: bool\n");
472 pygpu_state_program_point_size_set_doc,
473 ".. function:: program_point_size_set(enable)\n"
475 " If enabled, the derived point size is taken from the (potentially clipped) "
476 "shader builtin gl_PointSize.\n"
478 " :arg enable: True for shader builtin gl_PointSize.\n"
479 " :type enable: bool\n");
495 pygpu_state_active_framebuffer_get_doc,
496 ".. function:: active_framebuffer_get(enable)\n"
498 " Return the active frame-buffer in context.\n");
513#if (defined(__GNUC__) && !defined(__clang__))
514# pragma GCC diagnostic push
515# pragma GCC diagnostic ignored "-Wcast-function-type"
522 {
"clip_distances_set",
525 pygpu_state_clip_distances_set_doc},
529 pygpu_state_depth_test_set_doc},
533 pygpu_state_depth_test_get_doc},
537 pygpu_state_depth_mask_set_doc},
541 pygpu_state_depth_mask_get_doc},
545 pygpu_state_viewport_set_doc},
549 pygpu_state_viewport_get_doc},
553 pygpu_state_scissor_set_doc},
557 pygpu_state_scissor_get_doc},
561 pygpu_state_scissor_test_set_doc},
565 pygpu_state_line_width_set_doc},
569 pygpu_state_line_width_get_doc},
573 pygpu_state_point_size_set_doc},
577 pygpu_state_color_mask_set_doc},
581 pygpu_state_face_culling_set_doc},
585 pygpu_state_front_facing_set_doc},
586 {
"program_point_size_set",
589 pygpu_state_program_point_size_set_doc},
590 {
"active_framebuffer_get",
593 pygpu_state_active_framebuffer_get_doc},
594 {
nullptr,
nullptr, 0,
nullptr},
597#if (defined(__GNUC__) && !defined(__clang__))
598# pragma GCC diagnostic pop
604 "This module provides access to the gpu state.");
606 PyModuleDef_HEAD_INIT,
GPUFrameBuffer * GPU_framebuffer_active_get()
void GPU_program_point_size(bool enable)
void GPU_face_culling(eGPUFaceCullTest culling)
@ GPU_BLEND_ADDITIVE_PREMULT
@ GPU_BLEND_ALPHA_PREMULT
void GPU_blend(eGPUBlend blend)
void GPU_scissor_test(bool enable)
void GPU_line_width(float width)
eGPUBlend GPU_blend_get()
void GPU_depth_mask(bool depth)
eGPUDepthTest GPU_depth_test_get()
void GPU_color_mask(bool r, bool g, bool b, bool a)
void GPU_viewport_size_get_i(int coords[4])
void GPU_scissor(int x, int y, int width, int height)
float GPU_line_width_get()
void GPU_front_facing(bool invert)
void GPU_viewport(int x, int y, int width, int height)
void GPU_point_size(float size)
@ GPU_DEPTH_GREATER_EQUAL
void GPU_depth_test(eGPUDepthTest test)
bool GPU_depth_mask_get()
void GPU_scissor_get(int coords[4])
void GPU_clip_distances(int distances_enabled)
local_group_size(16, 16) .push_constant(Type b
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define BPYGPU_IS_INIT_OR_ERROR_OBJ
PyObject * BPyGPUFrameBuffer_CreatePyObject(GPUFrameBuffer *fb, bool shared_reference)
static PyObject * pygpu_state_scissor_set(PyObject *, PyObject *args)
static PyObject * pygpu_state_blend_get(PyObject *)
static PyObject * pygpu_state_viewport_set(PyObject *, PyObject *args)
static PyMethodDef pygpu_state__tp_methods[]
static PyObject * pygpu_state_program_point_size_set(PyObject *, PyObject *value)
PyDoc_STRVAR(pygpu_state_blend_set_doc, ".. function:: blend_set(mode)\n" "\n" " Defines the fixed pipeline blending equation.\n" "\n" " :arg mode: The type of blend mode.\n" "\n" " * ``NONE`` No blending.\n" " * ``ALPHA`` The original color channels are interpolated according to the alpha " "value.\n" " * ``ALPHA_PREMULT`` The original color channels are interpolated according to the " "alpha value with the new colors pre-multiplied by this value.\n" " * ``ADDITIVE`` The original color channels are added by the corresponding ones.\n" " * ``ADDITIVE_PREMULT`` The original color channels are added by the corresponding ones " "that are pre-multiplied by the alpha value.\n" " * ``MULTIPLY`` The original color channels are multiplied by the corresponding ones.\n" " * ``SUBTRACT`` The original color channels are subtracted by the corresponding ones.\n" " * ``INVERT`` The original color channels are replaced by its complementary color.\n" " :type mode: str\n")
static PyObject * pygpu_state_viewport_get(PyObject *, PyObject *)
static PyObject * pygpu_state_scissor_test_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_line_width_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_front_facing_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_point_size_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_active_framebuffer_get(PyObject *)
PyObject * bpygpu_state_init()
static PyObject * pygpu_state_depth_mask_get(PyObject *)
static PyObject * pygpu_state_face_culling_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_clip_distances_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_blend_set(PyObject *, PyObject *value)
static const PyC_StringEnumItems pygpu_state_depthtest_items[]
static PyObject * pygpu_state_depth_test_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_line_width_get(PyObject *)
static PyObject * pygpu_state_depth_test_get(PyObject *)
static PyObject * pygpu_state_depth_mask_set(PyObject *, PyObject *value)
static PyObject * pygpu_state_color_mask_set(PyObject *, PyObject *args)
static const PyC_StringEnumItems pygpu_state_faceculling_items[]
static PyObject * pygpu_state_scissor_get(PyObject *, PyObject *)
static PyModuleDef pygpu_state_module_def
static const PyC_StringEnumItems pygpu_state_blend_items[]
BLI_INLINE float fb(float length, float L)
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
int PyC_ParseStringEnum(PyObject *o, void *p)
const char * PyC_StringEnum_FindIDFromValue(const PyC_StringEnumItems *items, const int value)
int PyC_ParseBool(PyObject *o, void *p)
#define PyTuple_SET_ITEMS(op_arg,...)