[Mesa-dev] [PATCH] spirv: Fix building with SCons

Jason Ekstrand jason at jlekstrand.net
Fri Mar 30 23:09:09 UTC 2018


On March 30, 2018 09:40:13 Brian Paul <brianp at vmware.com> wrote:

OK, I'll have some patches soon but I'm stuck on one issue.

Around spriv_to_nir.c:2090 we have

if (operands & SpvImageOperandsConstOffsetsMask) {
gather_offsets = vtn_ssa_value(b, w[idx++]);
(*p++) = (nir_tex_src){};
}

The (nir_tex_src){} expression is not valid for MSVC (syntax error).  I
haven't figured out exactly what that's supposed to do.

It's a GCC extension. An initializer with empty braces initializer to zero. 
 I'm on my phone so I can't see any more context but that line strikes me 
as a bit weird.  We could add a NIR_TEX_SRC_INIT helper of this is useful.


Replacing it with (*p++) = (nir_tex_src)0; works but I'm not sure that's
correct.

I don't know what that does...


Ilia wrote the line in question.  Ilia?

-Brian



On 03/30/2018 09:25 AM, Brian Paul wrote:
Thanks, Neil.

This fixes the SCons build on Linux, but on Windows there's a whole
bunch of other issues:

c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(232):
error C2085:
'vtn_instruction_handler': not in formal parameter list
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(235):
error C2085:
'vtn_build_cfg': not in formal parameter list
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(237):
error C2146:
syntax error: missing ')' before identifier 'instruction_handler'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(237):
error C2081:
'vtn_instruction_handler': name in formal parameter list illegal
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(237):
error C2085:
'vtn_function_emit': not in formal parameter list
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(237):
error C2146:
syntax error: missing ',' before identifier 'instruction_handler'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(237):
error C2059:
syntax error: ')'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(241):
error C2146:
syntax error: missing ')' before identifier 'handler'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(241):
error C2081:
'vtn_instruction_handler': name in formal parameter list illegal
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(241):
error C2085:
'vtn_foreach_instruction': not in formal parameter list
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(241):
error C2146:
syntax error: missing ',' before identifier 'handler'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(241):
error C2059:
syntax error: ')'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(369):
error C2085:
'vtn_types_compatible': not in formal parameter list
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(504):
error C2061:
syntax error: identifier 'vtn_instruction_handler'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(505):
error C2059:
syntax error: '}'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(506):
error C2059:
syntax error: '}'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(597):
error C2036:
'vtn_value *': unknown size
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(607):
error C2037:
left of 'value_type' specifies undefined struct/union 'vtn_value'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(607):
error C2065:
'vtn_value_type_invalid': undeclared identifier
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(609):
error C2037:
left of 'value_type' specifies undefined struct/union 'vtn_value'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(611):
error C2036:
'vtn_value *': unknown size
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(618):
error C2037:
left of 'base_type' specifies undefined struct/union 'vtn_type'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(618):
error C2065:
'vtn_base_type_pointer': undeclared identifier
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(619):
error C2065:
'vtn_value_type_pointer': undeclared identifier
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(620):
error C2037:
left of 'pointer' specifies undefined struct/union 'vtn_value'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(620):
error C2037:
left of 'def' specifies undefined struct/union 'vtn_ssa_value'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(620):
warning C413
3: 'function': incompatible types - from 'vtn_type *' to 'nir_ssa_def *'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(620):
error C2198:
'vtn_pointer_from_ssa': too few arguments for call
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(622):
error C2065:
'vtn_value_type_ssa': undeclared identifier
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(623):
error C2037:
left of 'ssa' specifies undefined struct/union 'vtn_value'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(634):
error C2037:
left of 'value_type' specifies undefined struct/union 'vtn_value'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(645):
error C2065:
'vtn_value_type_constant': undeclared identifier
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(645):
error C2037:
left of 'constant' specifies undefined struct/union 'vtn_value'
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(645):
warning C403
3: 'vtn_constant_value' must return a value
c:\users\brian\projects\mesa\src\compiler\spirv\vtn_private.h(735):
warning C414
6: unary minus operator applied to unsigned type, result still unsigned
src\compiler\spirv\gl_spirv.c(89): error C2065:
'vtn_value_type_constant': undec
lared identifier
src\compiler\spirv\gl_spirv.c(250): warning C4013:
'vtn_foreach_instruction' und
efined; assuming extern returning int
src\compiler\spirv\gl_spirv.c(251): warning C4047: '=': 'const uint32_t
*' diffe
rs in levels of indirection from 'int'
src\compiler\spirv\gl_spirv.c(265): warning C4047: '=': 'const uint32_t
*' diffe
rs in levels of indirection from 'int'
scons: *** [build\windows-x86-debug\compiler\spirv\gl_spirv.obj] Error 2
scons: building terminated because of errors.


I'll take a quick look, but I'd appreciate it if the NIR people can look
too.

-Brian


On 03/30/2018 09:12 AM, Neil Roberts wrote:
The SCons build broke with commit ba975140d3c9 because a SPIR-V
function is called from Mesa main. This adds a convenience library for
SPIR-V and adds it to everything that was including nir. It also adds
both nir and spirv to drivers/x11/SConscript.

---

It would be great if someone who depends on SCons could test this. We
weren’t sure if there was a good reason why nir isn’t already included
in drivers/x11/SConscript and whether adding it might break some
platform.

src/compiler/Makefile.nir.am                  |  3 +-
src/compiler/SConscript                       |  1 +
src/compiler/SConscript.spirv                 | 54
+++++++++++++++++++++++++++
src/gallium/targets/dri/SConscript            |  1 +
src/gallium/targets/haiku-softpipe/SConscript |  1 +
src/gallium/targets/libgl-xlib/SConscript     |  1 +
src/gallium/targets/osmesa/SConscript         |  1 +
src/mesa/drivers/x11/SConscript               |  2 +
8 files changed, 63 insertions(+), 1 deletion(-)
create mode 100644 src/compiler/SConscript.spirv

diff --git a/src/compiler/Makefile.nir.am b/src/compiler/Makefile.nir.am
index 32e4145b70f..27dc129e57b 100644
--- a/src/compiler/Makefile.nir.am
+++ b/src/compiler/Makefile.nir.am
@@ -100,4 +100,5 @@ EXTRA_DIST += \
nir/nir_opt_algebraic.py            \
nir/tests \
nir/README \
-    SConscript.nir
+    SConscript.nir \
+    SConstript.spirv
diff --git a/src/compiler/SConscript b/src/compiler/SConscript
index 44509a9a95b..0a0c0737422 100644
--- a/src/compiler/SConscript
+++ b/src/compiler/SConscript
@@ -27,3 +27,4 @@ Export('compiler')
SConscript('SConscript.glsl')
SConscript('SConscript.nir')
+SConscript('SConscript.spirv')
diff --git a/src/compiler/SConscript.spirv
b/src/compiler/SConscript.spirv
new file mode 100644
index 00000000000..49410881d0b
--- /dev/null
+++ b/src/compiler/SConscript.spirv
@@ -0,0 +1,54 @@
+import common
+
+Import('*')
+
+from sys import executable as python_cmd
+
+env = env.Clone()
+
+env.MSVC2013Compat()
+
+env.Prepend(CPPPATH = [
+    '#include',
+    '#src',
+    '#src/mapi',
+    '#src/mesa',
+    '#src/gallium/include',
+    '#src/gallium/auxiliary',
+    '#src/compiler/nir',
+    '#src/compiler/spirv',
+])
+
+# Make generated headers reachable from the include path.
+env.Prepend(CPPPATH = [Dir('.').abspath, Dir('nir').abspath])
+env.Prepend(CPPPATH = [Dir('.').abspath, Dir('spirv').abspath])
+
+# spirv generated sources
+
+env.CodeGenerate(
+    target = 'spirv/spirv_info.c',
+    script = 'spirv/spirv_info_c.py',
+    source = ['spirv/spirv.core.grammar.json'],
+    command = python_cmd + ' $SCRIPT $SOURCE $TARGET'
+)
+
+env.CodeGenerate(
+    target = 'spirv/vtn_gather_types.c',
+    script = 'spirv/vtn_gather_types_c.py',
+    source = ['spirv/spirv.core.grammar.json'],
+    command = python_cmd + ' $SCRIPT $SOURCE $TARGET'
+)
+
+# parse Makefile.sources
+source_lists = env.ParseSourceList('Makefile.sources')
+
+spirv_sources = source_lists['SPIRV_FILES']
+spirv_sources += source_lists['SPIRV_GENERATED_FILES']
+
+spirv = env.ConvenienceLibrary(
+    target = 'spirv',
+    source = spirv_sources,
+)
+
+env.Alias('spirv', spirv)
+Export('spirv')
diff --git a/src/gallium/targets/dri/SConscript
b/src/gallium/targets/dri/SConscript
index f5c2818d04f..ff6ce3bf4e0 100644
--- a/src/gallium/targets/dri/SConscript
+++ b/src/gallium/targets/dri/SConscript
@@ -45,6 +45,7 @@ env.Prepend(LIBS = [
mesa,
glsl,
nir,
+    spirv,
gallium,
megadrivers_stub,
dri_common,
diff --git a/src/gallium/targets/haiku-softpipe/SConscript
b/src/gallium/targets/haiku-softpipe/SConscript
index f80c167d83b..89792fba132 100644
--- a/src/gallium/targets/haiku-softpipe/SConscript
+++ b/src/gallium/targets/haiku-softpipe/SConscript
@@ -10,6 +10,7 @@ env.Prepend(LIBS = [
mesa,
glsl,
nir,
+    spirv,
gallium
])
diff --git a/src/gallium/targets/libgl-xlib/SConscript
b/src/gallium/targets/libgl-xlib/SConscript
index a81ac793251..b94ef350b16 100644
--- a/src/gallium/targets/libgl-xlib/SConscript
+++ b/src/gallium/targets/libgl-xlib/SConscript
@@ -33,6 +33,7 @@ env.Prepend(LIBS = [
mesa,
glsl,
nir,
+    spirv,
gallium,
])
diff --git a/src/gallium/targets/osmesa/SConscript
b/src/gallium/targets/osmesa/SConscript
index 7be1b48c0b2..ccf7d5170c4 100644
--- a/src/gallium/targets/osmesa/SConscript
+++ b/src/gallium/targets/osmesa/SConscript
@@ -18,6 +18,7 @@ env.Prepend(LIBS = [
trace,
glsl,
nir,
+    spirv,
mesautil,
softpipe
])
diff --git a/src/mesa/drivers/x11/SConscript
b/src/mesa/drivers/x11/SConscript
index 59c8df4b3c2..b097dcc5900 100644
--- a/src/mesa/drivers/x11/SConscript
+++ b/src/mesa/drivers/x11/SConscript
@@ -21,6 +21,8 @@ env.Prepend(LIBS = [
compiler,
glsl,
mesa,
+    spirv,
+    nir,
])
sources = [

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=jUBTwdV-ZbIqzdYkHf7joC8YQGsiNykwd2SwNL6dy9o&s=YCAu-uChzunMQTwRO7KzIen2xSjERznwXmAXdUSrOXU&e=

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev





More information about the mesa-dev mailing list