WIP: Fix #103978 Python: Add deprecation warnings to GPUBatch program usage #105174
|
@ -54,44 +54,10 @@ int BlenderDisplayShader::get_tex_coord_attrib_location()
|
|||
/* --------------------------------------------------------------------
|
||||
* BlenderFallbackDisplayShader.
|
||||
*/
|
||||
|
||||
/* TODO move shaders to standalone .glsl file. */
|
||||
static const char *FALLBACK_VERTEX_SHADER =
|
||||
"uniform vec2 fullscreen;\n"
|
||||
"in vec2 texCoord;\n"
|
||||
"in vec2 pos;\n"
|
||||
"out vec2 texCoord_interp;\n"
|
||||
"\n"
|
||||
"vec2 normalize_coordinates()\n"
|
||||
"{\n"
|
||||
" return (vec2(2.0) * (pos / fullscreen)) - vec2(1.0);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = vec4(normalize_coordinates(), 0.0, 1.0);\n"
|
||||
" texCoord_interp = texCoord;\n"
|
||||
"}\n\0";
|
||||
|
||||
static const char *FALLBACK_FRAGMENT_SHADER =
|
||||
"uniform sampler2D image_texture;\n"
|
||||
"in vec2 texCoord_interp;\n"
|
||||
"out vec4 fragColor;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" fragColor = texture(image_texture, texCoord_interp);\n"
|
||||
"}\n\0";
|
||||
|
||||
static GPUShader *compile_fallback_shader(void)
|
||||
{
|
||||
/* NOTE: Compilation errors are logged to console. */
|
||||
GPUShader *shader = GPU_shader_create(FALLBACK_VERTEX_SHADER,
|
||||
FALLBACK_FRAGMENT_SHADER,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
"FallbackCyclesBlitShader");
|
||||
GPUShader *shader = GPU_shader_create_from_info_name("gpu_shader_cycles_display_fallback");
|
||||
return shader;
|
||||
}
|
||||
|
||||
|
|
|
@ -225,6 +225,7 @@ struct AddOperationExecutor {
|
|||
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE;
|
||||
add_inputs.interpolate_point_count = brush_settings_->flag &
|
||||
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_POINT_COUNT;
|
||||
add_inputs.interpolate_resolution = curves_orig_->attributes().contains("resolution");
|
||||
add_inputs.fallback_curve_length = brush_settings_->curve_length;
|
||||
add_inputs.fallback_point_count = std::max(2, brush_settings_->points_per_curve);
|
||||
add_inputs.transforms = &transforms_;
|
||||
|
@ -234,7 +235,7 @@ struct AddOperationExecutor {
|
|||
add_inputs.corner_normals_su = corner_normals_su;
|
||||
|
||||
if (add_inputs.interpolate_length || add_inputs.interpolate_shape ||
|
||||
add_inputs.interpolate_point_count) {
|
||||
add_inputs.interpolate_point_count || add_inputs.interpolate_resolution) {
|
||||
this->ensure_curve_roots_kdtree();
|
||||
add_inputs.old_roots_kdtree = self_->curve_roots_kdtree_;
|
||||
}
|
||||
|
|
|
@ -275,6 +275,7 @@ struct DensityAddOperationExecutor {
|
|||
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE;
|
||||
add_inputs.interpolate_point_count = brush_settings_->flag &
|
||||
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_POINT_COUNT;
|
||||
add_inputs.interpolate_resolution = curves_orig_->attributes().contains("resolution");
|
||||
add_inputs.fallback_curve_length = brush_settings_->curve_length;
|
||||
add_inputs.fallback_point_count = std::max(2, brush_settings_->points_per_curve);
|
||||
add_inputs.transforms = &transforms_;
|
||||
|
|
|
@ -25,6 +25,7 @@ struct AddCurvesOnMeshInputs {
|
|||
bool interpolate_length = false;
|
||||
bool interpolate_shape = false;
|
||||
bool interpolate_point_count = false;
|
||||
bool interpolate_resolution = false;
|
||||
float fallback_curve_length = 0.0f;
|
||||
int fallback_point_count = 0;
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ AddCurvesOnMeshOutputs add_curves_on_mesh(CurvesGeometry &curves,
|
|||
AddCurvesOnMeshOutputs outputs;
|
||||
|
||||
const bool use_interpolation = inputs.interpolate_length || inputs.interpolate_point_count ||
|
||||
inputs.interpolate_shape;
|
||||
inputs.interpolate_shape || inputs.interpolate_resolution;
|
||||
|
||||
Vector<float3> root_positions_cu;
|
||||
Vector<float3> bary_coords;
|
||||
|
@ -380,8 +380,24 @@ AddCurvesOnMeshOutputs add_curves_on_mesh(CurvesGeometry &curves,
|
|||
|
||||
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
|
||||
|
||||
if (bke::SpanAttributeWriter<int> resolution = attributes.lookup_for_write_span<int>(
|
||||
"resolution")) {
|
||||
if (inputs.interpolate_resolution) {
|
||||
interpolate_from_neighbors(
|
||||
neighbors_per_curve,
|
||||
12,
|
||||
[&](const int curve_i) { return resolution.span[curve_i]; },
|
||||
resolution.span.take_back(added_curves_num));
|
||||
resolution.finish();
|
||||
}
|
||||
else {
|
||||
resolution.span.take_back(added_curves_num).fill(12);
|
||||
}
|
||||
}
|
||||
|
||||
/* Explicitly set all other attributes besides those processed above to default values. */
|
||||
Set<std::string> attributes_to_skip{{"position", "curve_type", "surface_uv_coordinate"}};
|
||||
Set<std::string> attributes_to_skip{
|
||||
{"position", "curve_type", "surface_uv_coordinate", "resolution"}};
|
||||
attributes.for_all(
|
||||
[&](const bke::AttributeIDRef &id, const bke::AttributeMetaData /*meta_data*/) {
|
||||
if (attributes_to_skip.contains(id.name())) {
|
||||
|
|
|
@ -514,6 +514,9 @@ set(GLSL_SRC
|
|||
shaders/gpu_shader_gpencil_stroke_frag.glsl
|
||||
shaders/gpu_shader_gpencil_stroke_geom.glsl
|
||||
|
||||
shaders/gpu_shader_display_fallback_vert.glsl
|
||||
shaders/gpu_shader_display_fallback_frag.glsl
|
||||
|
||||
shaders/gpu_shader_cfg_world_clip_lib.glsl
|
||||
shaders/gpu_shader_colorspace_lib.glsl
|
||||
|
||||
|
|
|
@ -529,6 +529,9 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI
|
|||
}
|
||||
}
|
||||
|
||||
this->sort_inputs();
|
||||
|
||||
/* Resolving builtins must happen after the inputs have been sorted. */
|
||||
/* Builtin Uniforms */
|
||||
for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORMS; u_int++) {
|
||||
GPUUniformBuiltin u = static_cast<GPUUniformBuiltin>(u_int);
|
||||
|
@ -543,8 +546,6 @@ GLShaderInterface::GLShaderInterface(GLuint program, const shader::ShaderCreateI
|
|||
builtin_blocks_[u] = (block != nullptr) ? block->binding : -1;
|
||||
}
|
||||
|
||||
this->sort_inputs();
|
||||
|
||||
// this->debug_print();
|
||||
|
||||
glUseProgram(last_program);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
void main()
|
||||
{
|
||||
fragColor = texture(image_texture, texCoord_interp);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
vec2 normalize_coordinates()
|
||||
{
|
||||
return (vec2(2.0) * (pos / fullscreen)) - vec2(1.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(normalize_coordinates(), 0.0, 1.0);
|
||||
texCoord_interp = texCoord;
|
||||
}
|
|
@ -22,3 +22,15 @@ GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_merge)
|
|||
.vertex_source("gpu_shader_2D_image_vert.glsl")
|
||||
.fragment_source("gpu_shader_image_overlays_merge_frag.glsl")
|
||||
.do_static_compilation(true);
|
||||
|
||||
/* Cycles display driver fallback shader. */
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_cycles_display_fallback)
|
||||
.vertex_in(0, Type::VEC2, "pos")
|
||||
.vertex_in(1, Type::VEC2, "texCoord")
|
||||
.vertex_out(smooth_tex_coord_interp_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.push_constant(Type::VEC2, "fullscreen")
|
||||
.sampler(0, ImageType::FLOAT_2D, "image_texture")
|
||||
.vertex_source("gpu_shader_display_fallback_vert.glsl")
|
||||
.fragment_source("gpu_shader_display_fallback_frag.glsl")
|
||||
.do_static_compilation(true);
|
||||
|
|
Loading…
Reference in New Issue