[Mesa-dev] [PATCH 2/2] svga: implement MSAA alpha_to_one feature
Brian Paul
brianp at vmware.com
Mon Jul 24 20:02:08 UTC 2017
On 07/24/2017 11:05 AM, Charmaine Lee wrote:
>
>>From: Brian Paul <brianp at vmware.com>
>>Sent: Saturday, July 22, 2017 12:24 PM
>>To: mesa-dev at lists.freedesktop.org
>>Cc: Charmaine Lee; Neha Bhende
>>Subject: [PATCH 2/2] svga: implement MSAA alpha_to_one feature
>
>>The device doesn't directly support this feature so we implement it with
>>additional shader code which sets the color output(s) w component to
>>1.0 (or max_int or max_uint).
>
>>Fixes 16 Piglit ext_framebuffer_multisample/*alpha-to-one* tests.
>>---
>> src/gallium/drivers/svga/svga_context.h | 1 +
>> src/gallium/drivers/svga/svga_pipe_blend.c | 1 +
>> src/gallium/drivers/svga/svga_shader.h | 3 ++
>> src/gallium/drivers/svga/svga_state_fs.c | 18 +++++++++
>> src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 61 ++++++++++++++++++++++++++++-
>> 5 files changed, 83 insertions(+), 1 deletion(-)
>
> ...
>
>
>>diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
>>index 9f5cd4b..8984ce5 100644
>>--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
>>+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
>
> ...
>
> @@ -6378,6 +6393,47 @@ emit_pre_helpers(struct svga_shader_emitter_v10
> *emit)
>
>
>> /**
>>+ * The device has no direct support for the pipe_blend_state::alpha_to_one
>>+ * option so we implement it here with shader code.
>>+ */
>>+static void
>>+emit_alpha_to_one_instructions(struct svga_shader_emitter_v10 *emit,
>>+ unsigned fs_color_tmp_index)
>>+{
>>+ unsigned i;
>>+
>>+ for (i = 0; i < emit->fs.num_color_outputs; i++) {
>>+ struct tgsi_full_dst_register color_dst;
>>+
>>+ if (fs_color_tmp_index != INVALID_INDEX && i == 0) {
>>+ /* write to the temp color register */
>>+ color_dst = make_dst_temp_reg(fs_color_tmp_index);
>>+ }
>>+ else {
>>+ /* write directly to the color[i] output */
>>+ color_dst = make_dst_output_reg(emit->fs.color_out_index[i]);
>>+ }
>>+
>>+ color_dst = writemask_dst(&color_dst, TGSI_WRITEMASK_W);
>>+
>>+ /* Depending on type of the render target, we either set alpha/w to
>>+ * 1.0f, or max(int) or max(uint).
>>+ */
>>+ struct tgsi_full_src_register one;
>>+ if (emit->key.fs.int_render_target_mask & (1 << i)) {
>>+ one = make_immediate_reg_int(emit, 0x8fffffff);
>>+ } else if (emit->key.fs.uint_render_target_mask & (1 << i)) {
>>+ one = make_immediate_reg_int(emit, 0xffffffff);
>>+ } else {
>>+ one = make_immediate_reg_float(emit, 1.0f);
>>+ }
>
> How about moving the various "make one immediate" outside of the loop?
> No need to repeatedly looking for the same immediate.
Roland reminded me that alpha-to-one is not applicable to int buffers so
I can just remove that.
-Brian
More information about the mesa-dev
mailing list