Discussion:
[Bug 104119] radv: OpBitFieldInsert produces 0 with a loop counter for Insert
Add Reply
b***@freedesktop.org
2017-12-05 15:53:05 UTC
Reply
Permalink
Raw Message
https://bugs.freedesktop.org/show_bug.cgi?id=104119

Bug ID: 104119
Summary: radv: OpBitFieldInsert produces 0 with a loop counter
for Insert
Product: Mesa
Version: git
Hardware: Other
OS: All
Status: NEW
Severity: normal
Priority: medium
Component: Drivers/Vulkan/radeon
Assignee: mesa-***@lists.freedesktop.org
Reporter: ***@feralinteractive.com
QA Contact: mesa-***@lists.freedesktop.org

Created attachment 135980
--> https://bugs.freedesktop.org/attachment.cgi?id=135980&action=edit
test application that reproduces the bug

On RADV, the SPIR-V OpBitFieldInsert opcode produces 0 when the Insert
parameter derives from a variable used as a loop counter. For example, the
following GLSL compute shader writes 0 to the first 8 elements of the buffer at
binding 0:

#version 450 core
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout (std430, set = 0, binding = 0)
restrict writeonly buffer u2_cs { uint u2[]; };

void main()
{
for (int i = 0; i < 8; i++)
u2[i] = bitfieldInsert(0, i, 16, 2);
}


I've attached a program that reproduces the bug.

I'm using the LLVM release_50 branch at revision 318947 and the Mesa master
branch at 20d37da597653201d2c524434907e817bd03b1d0.
--
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.
b***@freedesktop.org
2017-12-05 15:54:01 UTC
Reply
Permalink
Raw Message
https://bugs.freedesktop.org/show_bug.cgi?id=104119

--- Comment #1 from James Legg <***@feralinteractive.com> ---
Created attachment 135981
--> https://bugs.freedesktop.org/attachment.cgi?id=135981&action=edit
SPIR-V disassembly of test shader
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
b***@freedesktop.org
2017-12-05 15:54:43 UTC
Reply
Permalink
Raw Message
https://bugs.freedesktop.org/show_bug.cgi?id=104119

--- Comment #2 from James Legg <***@feralinteractive.com> ---
Created attachment 135982
--> https://bugs.freedesktop.org/attachment.cgi?id=135982&action=edit
Output from RADV_DEBUG=shaders
--
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.
b***@freedesktop.org
2017-12-05 17:27:03 UTC
Reply
Permalink
Raw Message
https://bugs.freedesktop.org/show_bug.cgi?id=104119

--- Comment #3 from Samuel Pitoiset <***@gmail.com> ---
Something is wrong in the NIR.
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
b***@freedesktop.org
2017-12-05 17:34:07 UTC
Reply
Permalink
Raw Message
https://bugs.freedesktop.org/show_bug.cgi?id=104119

--- Comment #4 from Samuel Pitoiset <***@gmail.com> ---
Possible fix:

diff --git i/src/amd/vulkan/radv_shader.c w/src/amd/vulkan/radv_shader.c
index 4a3fdfa80e..0b19d23fa2 100644
--- i/src/amd/vulkan/radv_shader.c
+++ w/src/amd/vulkan/radv_shader.c
@@ -66,6 +66,7 @@ static const struct nir_shader_compiler_options nir_options =
{
.lower_extract_byte = true,
.lower_extract_word = true,
.lower_ffma = true,
+ .lower_bitfield_insert = true,
.max_unroll_iterations = 32
};
--
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.
b***@freedesktop.org
2017-12-05 17:51:03 UTC
Reply
Permalink
Raw Message
https://bugs.freedesktop.org/show_bug.cgi?id=104119

--- Comment #5 from Samuel Pitoiset <***@gmail.com> ---
Patch is on the list.

https://patchwork.freedesktop.org/series/34930/
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
b***@freedesktop.org
2017-12-06 11:57:17 UTC
Reply
Permalink
Raw Message
https://bugs.freedesktop.org/show_bug.cgi?id=104119

--- Comment #6 from James Legg <***@feralinteractive.com> ---
I've submitted another patch that fixes the constant folding that was going
wrong:

https://patchwork.freedesktop.org/patch/191977/
--
You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.
b***@freedesktop.org
2017-12-07 09:31:05 UTC
Reply
Permalink
Raw Message
https://bugs.freedesktop.org/show_bug.cgi?id=104119

Samuel Pitoiset <***@gmail.com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED

--- Comment #7 from Samuel Pitoiset <***@gmail.com> ---
Fixed.

https://cgit.freedesktop.org/mesa/mesa/commit/?id=947470d10ba5ab11a75f0e19e124b189ff3fd8b2
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
Loading...