Bug 100274 - LunarG Vulkan smoke test fragement shader compiling issue
Summary: LunarG Vulkan smoke test fragement shader compiling issue
Status: RESOLVED NOTOURBUG
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Vulkan/intel (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium major
Assignee: Intel 3D Bugs Mailing List
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-19 01:55 UTC by Randy
Modified: 2017-03-19 03:02 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Randy 2017-03-19 01:55:34 UTC
Run smoketest from LunarG, failed

ASSERT: Scalar FS validation failed!
mov(8) vgrf7+3.0:F, vgrf3:F 
brw_fs_validate.cpp:47: inst->dst.offset / REG_SIZE + regs_written(inst) <= alloc.sizes[inst->dst.nr]

(gdb) bt
#0  0x00007ffff6b5f428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff6b6102a in __GI_abort () at abort.c:89
#2  0x00007ffff2f58acf in fs_visitor::validate (this=0x7fffffffb0b0) at brw_fs_validate.cpp:46
#3  0x00007ffff2f1fa76 in fs_visitor::optimize (this=0x7fffffffb0b0) at brw_fs.cpp:5590
#4  0x00007ffff2f23a6e in fs_visitor::run_fs (this=0x7fffffffb0b0, allow_spilling=true, do_rep_send=false) at brw_fs.cpp:6118
#5  0x00007ffff2f24959 in brw_compile_fs (compiler=0x6fac70, log_data=0x0, mem_ctx=0x99ca60, key=0x7fffffffc5a0, prog_data=0x7fffffffc640, 
    src_shader=0x99d0a0, prog=0x0, shader_time_index8=-1, shader_time_index16=-1, allow_spilling=true, use_rep_send=false, vue_map=0x0, 
    final_assembly_size=0x7fffffffc50c, error_str=0x0) at brw_fs.cpp:6436
#6  0x00007ffff2ed7ac9 in anv_pipeline_compile_fs (pipeline=0x995480, cache=0x0, info=0x7fffffffd350, module=0x994450, entrypoint=0x453194 "main", 
    spec_info=0x0) at anv_pipeline.c:864
#7  0x00007ffff2ed8c00 in anv_pipeline_init (pipeline=0x995480, device=0x992820, cache=0x0, pCreateInfo=0x7fffffffd350, alloc=0x992828)
    at anv_pipeline.c:1243
#8  0x00007ffff310e291 in gen9_graphics_pipeline_create (_device=0x992820, cache=0x0, pCreateInfo=0x7fffffffd350, pAllocator=0x0, pPipeline=0x68d4b0)
    at genX_pipeline.c:1451
#9  0x00007ffff310ebe6 in gen9_CreateGraphicsPipelines (_device=0x992820, pipelineCache=0x0, count=1, pCreateInfos=0x7fffffffd350, pAllocator=0x0, 
    pPipelines=0x68d4b0) at genX_pipeline.c:1651
#10 0x00007ffff3413c7b in vkCreateGraphicsPipelines (device=0x992820, pipelineCache=0x0, createInfoCount=1, pCreateInfos=0x7fffffffd350, pAllocator=0x0, 
    pPipelines=0x68d4b0) at /home/nuc/vulkan/vulkan-basic-samples/LunarGSamples/loader/trampoline.c:1372
#11 0x0000000000424039 in Smoke::create_pipeline (this=0x68bcb0) at /home/nuc/vulkan/vulkan-basic-samples/LunarGSamples/demos/smoke/Smoke.cpp:367
#12 0x00000000004232c3 in Smoke::attach_shell (this=0x68bcb0, sh=...) at /home/nuc/vulkan/vulkan-basic-samples/LunarGSamples/demos/smoke/Smoke.cpp:124
#13 0x0000000000446894 in Shell::create_context (this=0x7fffffffd790) at /home/nuc/vulkan/vulkan-basic-samples/LunarGSamples/demos/smoke/Shell.cpp:282
#14 0x0000000000452062 in ShellXcb::run (this=0x7fffffffd790) at /home/nuc/vulkan/vulkan-basic-samples/LunarGSamples/demos/smoke/ShellXcb.cpp:331
#15 0x00000000004357a7 in main (argc=1, argv=0x7fffffffda08) at /home/nuc/vulkan/vulkan-basic-samples/LunarGSamples/demos/smoke/Main.cpp:47
Comment 1 Jason Ekstrand 2017-03-19 01:59:18 UTC
I've seen issues like this many times and the issue is almost always that they have some input or output to a shader that doesn't have an explicit location specified.  Could you please double-check all the shaders for that.
Comment 2 Randy 2017-03-19 02:01:43 UTC
The fragement shader is converted to spir-v IR through glslangValidator tool

# glslangValidator -V -H -o Smoke.frag.spv Smoke.frag

The Smoke.frag.spv is correct and can be disassembled as

# spirv-dis Smoke.frag.spv

; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 1
; Bound: 19
; Schema: 0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %main "main" %fragcolor %color
               OpExecutionMode %main OriginUpperLeft
               OpSource ESSL 310
               OpName %main "main"
               OpName %fragcolor "fragcolor"
               OpName %color "color"
               OpDecorate %fragcolor Location 0
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
      %float = OpTypeFloat 32
    %v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
  %fragcolor = OpVariable %_ptr_Output_v4float Output
    %v3float = OpTypeVector %float 3
%_ptr_Input_v3float = OpTypePointer Input %v3float
      %color = OpVariable %_ptr_Input_v3float Input
  %float_0_5 = OpConstant %float 0.5
       %main = OpFunction %void None %3
          %5 = OpLabel
         %13 = OpLoad %v3float %color
         %15 = OpCompositeExtract %float %13 0
         %16 = OpCompositeExtract %float %13 1
         %17 = OpCompositeExtract %float %13 2
         %18 = OpCompositeConstruct %v4float %15 %16 %17 %float_0_5
               OpStore %fragcolor %18
               OpReturn
               OpFunctionEnd
Comment 3 Jason Ekstrand 2017-03-19 02:06:09 UTC
As I suspected the %color input variable isn't decorated with a location.  If you edit the GLSL for both fragment and vertex shaders to make sure it had a location on both sides of the interface, that should fix it.
Comment 4 Jason Ekstrand 2017-03-19 02:13:12 UTC
As a side-note, one of these days we should add an assert to the SPIR-V -> NIR pass that gives a nice descriptive name if someone has an input or output variable without a location.
Comment 5 Randy 2017-03-19 02:28:41 UTC
(In reply to Jason Ekstrand from comment #3)
> As I suspected the %color input variable isn't decorated with a location. 
> If you edit the GLSL for both fragment and vertex shaders to make sure it
> had a location on both sides of the interface, that should fix it.

Thanks Jason

The issue can be fixed by adding layout(location = 0) to input variable "color". We may need emphasize it in spec, i.e. the attribute location should be set explicitly. It's a little confusing, as the game developer may assume it's set to 0 implicitly.

diff --git a/LunarGSamples/demos/smoke/Smoke.frag b/LunarGSamples/demos/smoke/Smoke.frag
index e07a46f..82bee59 100644
--- a/LunarGSamples/demos/smoke/Smoke.frag
+++ b/LunarGSamples/demos/smoke/Smoke.frag
@@ -2,7 +2,7 @@
 
 precision highp float;
 
-in vec3 color;
+layout(location = 0) in vec3 color;
 
 layout(location = 0) out vec4 fragcolor;
Comment 6 Jason Ekstrand 2017-03-19 03:02:15 UTC
I've filed a bug against GLSLang asking them to error out in this case.  That should solve 90% of the user error here.

https://github.com/KhronosGroup/glslang/issues/781


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.