26 int2 size,
int sides,
float rotation,
float roundness,
float catadioptric,
float lens_shift)
31 catadioptric(catadioptric),
32 lens_shift(lens_shift)
44 return a.size ==
b.size && a.sides ==
b.sides && a.rotation ==
b.rotation &&
45 a.roundness ==
b.roundness && a.catadioptric ==
b.catadioptric &&
46 a.lens_shift ==
b.lens_shift;
57 return (
M_PI * 2.0f) / sides;
66 return angle - offset;
76 : result(context.create_result(
ResultType::Color))
78 GPUShader *shader = context.get_shader(
"compositor_bokeh_image");
87 this->result.allocate_texture(
Domain(size),
false);
88 this->result.bind_as_image(shader,
"output_img");
92 this->result.unbind_as_image();
98 this->result.release();
108 map_.remove_if([](
auto item) {
return !item.value->needed; });
112 for (
auto &value : map_.values()) {
113 value->needed =
false;
125 const BokehKernelKey key(size, sides, rotation, roundness, catadioptric, lens_shift);
127 auto &bokeh_kernel = *map_.lookup_or_add_cb(key, [&]() {
128 return std::make_unique<BokehKernel>(
129 context, size, sides, rotation, roundness, catadioptric, lens_shift);
132 bokeh_kernel.needed =
true;
133 return bokeh_kernel.result;
void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value)
void GPU_shader_bind(GPUShader *shader)
struct GPUShader GPUShader
Result & get(Context &context, int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift)
BokehKernelKey(int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift)
BokehKernel(Context &context, int2 size, int sides, float rotation, float roundness, float catadioptric, float lens_shift)
local_group_size(16, 16) .push_constant(Type b
static float compute_exterior_angle(int sides)
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
static float compute_rotation(float angle, int sides)
void compute_dispatch_threads_at_least(GPUShader *shader, int2 threads_range, int2 local_size=int2(16))
VecBase< float, 4 > float4
uint64_t get_default_hash(const T &v)
unsigned __int64 uint64_t