struct ureg_src tc;
struct ureg_src csc[3];
struct ureg_src sampler[3];
+ struct ureg_src lumakey;
struct ureg_dst texel;
struct ureg_dst fragment;
+ struct ureg_dst temp[2];
unsigned i;
shader = ureg_create(PIPE_SHADER_FRAGMENT);
csc[i] = ureg_DECL_constant(shader, i);
sampler[i] = ureg_DECL_sampler(shader, i);
}
+
+ for (i = 0; i < 2; ++i)
+ temp[i] = ureg_DECL_temporary(shader);
+
+ lumakey = ureg_DECL_constant(shader, 3);
texel = ureg_DECL_temporary(shader);
fragment = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, 0);
for (i = 0; i < 3; ++i)
ureg_DP4(shader, ureg_writemask(fragment, TGSI_WRITEMASK_X << i), csc[i], ureg_src(texel));
- ureg_MOV(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
+ ureg_MOV(shader, ureg_writemask(temp[0], TGSI_WRITEMASK_W),
+ ureg_scalar(ureg_src(texel), TGSI_SWIZZLE_Z));
+ ureg_SLE(shader, ureg_writemask(temp[1],TGSI_WRITEMASK_W),
+ ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_X));
+ ureg_SGT(shader, ureg_writemask(temp[0],TGSI_WRITEMASK_W),
+ ureg_src(temp[0]), ureg_scalar(lumakey, TGSI_SWIZZLE_Y));
+ ureg_MAX(shader, ureg_writemask(fragment, TGSI_WRITEMASK_W),
+ ureg_src(temp[0]), ureg_src(temp[1]));
+
+ for (i = 0; i < 2; ++i)
+ ureg_release_temporary(shader, temp[i]);
ureg_release_temporary(shader, texel);
ureg_END(shader);
}
void
-vl_compositor_set_csc_matrix(struct vl_compositor_state *s, vl_csc_matrix const *matrix)
+vl_compositor_set_csc_matrix(struct vl_compositor_state *s,
+ vl_csc_matrix const *matrix,
+ float luma_min, float luma_max)
{
struct pipe_transfer *buf_transfer;
assert(s);
- memcpy
- (
- pipe_buffer_map(s->pipe, s->csc_matrix,
- PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &buf_transfer),
- matrix,
- sizeof(vl_csc_matrix)
- );
+ float *ptr = pipe_buffer_map(s->pipe, s->csc_matrix,
+ PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
+ &buf_transfer);
+
+ memcpy(ptr, matrix, sizeof(vl_csc_matrix));
+
+ ptr += sizeof(vl_csc_matrix)/sizeof(float);
+ ptr[0] = luma_min;
+ ptr[1] = luma_max;
pipe_buffer_unmap(s->pipe, buf_transfer);
}
pipe->screen,
PIPE_BIND_CONSTANT_BUFFER,
PIPE_USAGE_DEFAULT,
- sizeof(csc_matrix)
+ sizeof(csc_matrix) + 2*sizeof(float)
);
vl_compositor_clear_layers(s);
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, &csc_matrix);
- vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)&csc_matrix);
+ vl_compositor_set_csc_matrix(s, (const vl_csc_matrix *)&csc_matrix, 1.0f, 0.0f);
return true;
}
vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &vmixer->csc);
if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc);
+ vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, 1.0f, 0.0f);
*mixer = vlAddDataHTAB(vmixer);
if (*mixer == 0) {
else
memcpy(vmixer->csc, vdp_csc, sizeof(vl_csc_matrix));
if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
- vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc);
+ vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, 1.0f, 0.0f);
break;
case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL: