"DCL SV[0], THREAD_ID\n"
"DCL SV[1], BLOCK_ID\n"
- "DCL CONST[0..5]\n"
+ "DCL CONST[0..6]\n"
"DCL SVIEW[0..2], RECT, FLOAT\n"
"DCL SAMP[0..2]\n"
"DCL TEMP[0..7]\n"
"IMM[0] UINT32 { 8, 8, 1, 0}\n"
- "IMM[1] FLT32 { 1.0, 2.0, 0.0, 0.0}\n"
+ "IMM[1] FLT32 { 1.0, 0.0, 0.0, 0.0}\n"
"UMAD TEMP[0].xy, SV[1].xyyy, IMM[0].xyyy, SV[0].xyyy\n"
/* Translate */
"UADD TEMP[2].xy, TEMP[0].xyyy, -CONST[5].xyxy\n"
"U2F TEMP[2].xy, TEMP[2].xyyy\n"
- "DIV TEMP[3].xy, TEMP[2].xyyy, IMM[1].yyyy\n"
+ "MUL TEMP[3].xy, TEMP[2].xyyy, CONST[6].xyyy\n"
/* Scale */
"DIV TEMP[2].xy, TEMP[2].xyyy, CONST[3].zwww\n"
static bool
set_viewport(struct vl_compositor_state *s,
- struct cs_viewport *drawn)
+ struct cs_viewport *drawn,
+ struct pipe_sampler_view **samplers)
{
struct pipe_transfer *buf_transfer;
ptr_float = (float *)ptr_int;
*ptr_float++ = drawn->sampler0_w;
- *ptr_float = drawn->sampler0_h;
+ *ptr_float++ = drawn->sampler0_h;
+
+ /* compute_shader_video_buffer uses pixel coordinates based on the
+ * Y sampler dimensions. If U/V are using separate planes and are
+ * subsampled, we need to scale the coordinates */
+ if (samplers[1]) {
+ float h_ratio = samplers[1]->texture->width0 /
+ (float) samplers[0]->texture->width0;
+ *ptr_float++ = h_ratio;
+ float v_ratio = samplers[1]->texture->height0 /
+ (float) samplers[0]->texture->height0;
+ *ptr_float++ = v_ratio;
+ }
pipe_buffer_unmap(s->pipe, buf_transfer);
return true;
drawn.translate_y = (int)layer->viewport.translate[1];
drawn.sampler0_w = (float)layer->sampler_views[0]->texture->width0;
drawn.sampler0_h = (float)layer->sampler_views[0]->texture->height0;
- set_viewport(s, &drawn);
+ set_viewport(s, &drawn, samplers);
c->pipe->bind_sampler_states(c->pipe, PIPE_SHADER_COMPUTE, 0,
num_sampler_views, layer->samplers);