Vulkan: Push constants #104880

Merged
Jeroen Bakker merged 73 commits from Jeroen-Bakker/blender:vulkan-push-constants into main 2023-03-06 12:29:06 +01:00
3 changed files with 94 additions and 1 deletions
Showing only changes of commit 28220c4505 - Show all commits

View File

@ -190,6 +190,9 @@ static int stroke_march_next_point(const bGPDstroke *gps,
float *pressure,
float *strength,
float *vert_color,
float *uv_fac,
float *uv_fill,
float *uv_rot,
float *ratio_result,
int *index_from,
int *index_to)
@ -271,6 +274,10 @@ static int stroke_march_next_point(const bGPDstroke *gps,
gps->points[next_point_index].pressure, gps->points[*index_from].pressure, vratio);
*strength = interpf(
gps->points[next_point_index].strength, gps->points[*index_from].strength, vratio);
*uv_fac = interpf(gps->points[next_point_index].uv_fac, gps->points[*index_from].uv_fac, vratio);
*uv_rot = interpf(gps->points[next_point_index].uv_rot, gps->points[*index_from].uv_rot, vratio);
interp_v2_v2v2(
uv_fill, gps->points[*index_from].uv_fill, gps->points[next_point_index].uv_fill, vratio);
interp_v4_v4v4(vert_color,
gps->points[*index_from].vert_color,
gps->points[next_point_index].vert_color,
@ -474,6 +481,7 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
int next_point_index = 1;
int i = 0;
float pressure, strength, ratio_result;
float uv_fac, uv_rot, uv_fill[2];
float vert_color[4];
int index_from, index_to;
float last_coord[3];
@ -504,6 +512,9 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
&pressure,
&strength,
vert_color,
&uv_fac,
uv_fill,
&uv_rot,
&ratio_result,
&index_from,
&index_to)) > -1) {
@ -514,6 +525,10 @@ bool BKE_gpencil_stroke_sample(bGPdata *gpd,
copy_v3_v3(&pt2->x, last_coord);
new_pt[i].pressure = pressure;
new_pt[i].strength = strength;
new_pt[i].uv_fac = uv_fac;
new_pt[i].uv_rot = uv_rot;
copy_v2_v2(new_pt[i].uv_fill, uv_fill);
memcpy(new_pt[i].vert_color, vert_color, sizeof(float[4]));
if (select) {
new_pt[i].flag |= GP_SPOINT_SELECT;

View File

@ -85,7 +85,7 @@
.type = TEX_IMAGE, \
.ima = NULL, \
.stype = 0, \
.flag = TEX_CHECKER_ODD, \
.flag = TEX_CHECKER_ODD | TEX_NO_CLAMP, \
.imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA, \
.extend = TEX_REPEAT, \
.cropxmin = 0.0, \

View File

@ -227,6 +227,72 @@ static PyObject *pygpu_state_viewport_get(PyObject *UNUSED(self), PyObject *UNUS
return ret;
}
PyDoc_STRVAR(pygpu_state_scissor_set_doc,
".. function:: scissor_set(x, y, xsize, ysize)\n"
"\n"
" Specifies the scissor area of the active framebuffer.\n"
" Note: The scissor state is not saved upon framebuffer rebind.\n"
"\n"
" :arg x, y: lower left corner of the scissor rectangle, in pixels.\n"
" :type x, y: int\n"
" :arg xsize, ysize: width and height of the scissor rectangle.\n"
" :type xsize, ysize: int\n");
static PyObject *pygpu_state_scissor_set(PyObject *UNUSED(self), PyObject *args)
{
int x, y, xsize, ysize;
if (!PyArg_ParseTuple(args, "iiii:scissor_set", &x, &y, &xsize, &ysize)) {
return NULL;
}
GPU_scissor(x, y, xsize, ysize);
Py_RETURN_NONE;
}
PyDoc_STRVAR(pygpu_state_scissor_get_doc,
".. function:: scissor_get()\n"
"\n"
" Retrieve the scissors of the active framebuffer.\n"
" Note: Only valid between 'scissor_set' and a framebuffer rebind.\n"
"\n"
" :return: The scissor of the active framebuffer as a tuple\n"
" (x, y, xsize, ysize).\n"
" x, y: lower left corner of the scissor rectangle, in pixels.\n"
" xsize, ysize: width and height of the scissor rectangle.\n"
" :rtype: tuple(int, int, int, int)\n");
static PyObject *pygpu_state_scissor_get(PyObject *UNUSED(self), PyObject *UNUSED(args))
{
int scissor[4];
GPU_scissor_get(scissor);
PyObject *ret = PyTuple_New(4);
PyTuple_SET_ITEMS(ret,
PyLong_FromLong(scissor[0]),
PyLong_FromLong(scissor[1]),
PyLong_FromLong(scissor[2]),
PyLong_FromLong(scissor[3]));
return ret;
}
PyDoc_STRVAR(pygpu_state_scissor_test_set_doc,
".. function:: scissor_test_set(enable)\n"
"\n"
" Enable/disable scissor testing on the active framebuffer.\n"
"\n"
" :arg enable:\n"
" True - enable scissor testing.\n"
" False - disable scissor testing.\n"
" :type enable: bool\n");
static PyObject *pygpu_state_scissor_test_set(PyObject *UNUSED(self), PyObject *value)
{
bool enabled;
if (!PyC_ParseBool(value, &enabled)) {
return NULL;
}
GPU_scissor_test(enabled);
Py_RETURN_NONE;
}
PyDoc_STRVAR(pygpu_state_line_width_set_doc,
".. function:: line_width_set(width)\n"
"\n"
@ -394,6 +460,18 @@ static struct PyMethodDef pygpu_state__tp_methods[] = {
(PyCFunction)pygpu_state_viewport_get,
METH_NOARGS,
pygpu_state_viewport_get_doc},
{"scissor_set",
(PyCFunction)pygpu_state_scissor_set,
METH_VARARGS,
pygpu_state_scissor_set_doc},
{"scissor_get",
(PyCFunction)pygpu_state_scissor_get,
METH_NOARGS,
pygpu_state_scissor_get_doc},
{"scissor_test_set",
(PyCFunction)pygpu_state_scissor_test_set,
METH_VARARGS,
pygpu_state_scissor_test_set_doc},
{"line_width_set",
(PyCFunction)pygpu_state_line_width_set,
METH_O,