Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
2b5b41bb
Commit
2b5b41bb
authored
Feb 08, 2016
by
John Kessenich
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch GitHub 'master' into khronosmaster
parents
759ccde4
103bef9d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
55 deletions
+99
-55
GlslangToSpv.cpp
SPIRV/GlslangToSpv.cpp
+19
-2
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+33
-0
SpvBuilder.h
SPIRV/SpvBuilder.h
+4
-0
spirv.hpp
SPIRV/spirv.hpp
+3
-4
spv.aggOps.frag.out
Test/baseResults/spv.aggOps.frag.out
+40
-49
No files found.
SPIRV/GlslangToSpv.cpp
View file @
2b5b41bb
...
...
@@ -1570,7 +1570,12 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
spvType
=
builder
.
makeFloatType
(
64
);
break
;
case
glslang
:
:
EbtBool
:
spvType
=
builder
.
makeBoolType
();
// "transparent" bool doesn't exist in SPIR-V. The GLSL convention is
// a 32-bit int where non-0 means true.
if
(
explicitLayout
!=
glslang
::
ElpNone
)
spvType
=
builder
.
makeUintType
(
32
);
else
spvType
=
builder
.
makeBoolType
();
break
;
case
glslang
:
:
EbtInt
:
spvType
=
builder
.
makeIntType
(
32
);
...
...
@@ -1764,9 +1769,21 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
return
spvType
;
}
// Wrap the builder's accessChainLoad to:
// - localize handling of RelaxedPrecision
// - use the SPIR-V inferred type instead of another conversion of the glslang type
// (avoids unnecessary work and possible type punning for structures)
// - do conversion of concrete to abstract type
spv
::
Id
TGlslangToSpvTraverser
::
accessChainLoad
(
const
glslang
::
TType
&
type
)
{
return
builder
.
accessChainLoad
(
TranslatePrecisionDecoration
(
type
),
convertGlslangToSpvType
(
type
));
spv
::
Id
nominalTypeId
=
builder
.
accessChainGetInferredType
();
spv
::
Id
loadedId
=
builder
.
accessChainLoad
(
TranslatePrecisionDecoration
(
type
),
nominalTypeId
);
// Need to convert to abstract types when necessary
if
(
builder
.
isScalarType
(
nominalTypeId
)
&&
type
.
getBasicType
()
==
glslang
::
EbtBool
&&
nominalTypeId
!=
builder
.
makeBoolType
())
loadedId
=
builder
.
createBinOp
(
spv
::
OpINotEqual
,
builder
.
makeBoolType
(),
loadedId
,
builder
.
makeUintConstant
(
0
));
return
loadedId
;
}
// Decide whether or not this type should be
...
...
SPIRV/SpvBuilder.cpp
View file @
2b5b41bb
...
...
@@ -1990,6 +1990,39 @@ Id Builder::accessChainGetLValue()
return
lvalue
;
}
// comment in header
Id
Builder
::
accessChainGetInferredType
()
{
// anything to operate on?
if
(
accessChain
.
base
==
NoResult
)
return
NoType
;
Id
type
=
getTypeId
(
accessChain
.
base
);
// do initial dereference
if
(
!
accessChain
.
isRValue
)
type
=
getContainedTypeId
(
type
);
// dereference each index
for
(
auto
deref
:
accessChain
.
indexChain
)
{
if
(
isStructType
(
type
))
type
=
getContainedTypeId
(
type
,
getConstantScalar
(
deref
));
else
type
=
getContainedTypeId
(
type
);
}
// dereference swizzle
if
(
accessChain
.
swizzle
.
size
()
==
1
)
type
=
getContainedTypeId
(
type
);
else
if
(
accessChain
.
swizzle
.
size
()
>
1
)
type
=
makeVectorType
(
getContainedTypeId
(
type
),
accessChain
.
swizzle
.
size
());
// dereference component selection
if
(
accessChain
.
component
)
type
=
getContainedTypeId
(
type
);
return
type
;
}
void
Builder
::
dump
(
std
::
vector
<
unsigned
int
>&
out
)
const
{
// Header, before first instructions:
...
...
SPIRV/SpvBuilder.h
View file @
2b5b41bb
...
...
@@ -506,6 +506,10 @@ public:
// get the direct pointer for an l-value
Id
accessChainGetLValue
();
// Get the inferred SPIR-V type of the result of the current access chain,
// based on the type of the base and the chain of dereferences.
Id
accessChainGetInferredType
();
void
dump
(
std
::
vector
<
unsigned
int
>&
)
const
;
void
createBranch
(
Block
*
block
);
...
...
SPIRV/spirv.hpp
View file @
2b5b41bb
...
...
@@ -39,8 +39,8 @@
// "Mask" in their name, and a parallel enum that has the shift
// amount (1 << x) for each corresponding enumerant.
#ifndef spirv_H
#define spirv_H
#ifndef spirv_H
PP
#define spirv_H
PP
namespace
spv
{
...
...
@@ -874,5 +874,4 @@ inline KernelProfilingInfoMask operator|(KernelProfilingInfoMask a, KernelProfil
}
// end namespace spv
#endif // #ifndef spirv_H
#endif // #ifndef spirv_HPP
Test/baseResults/spv.aggOps.frag.out
View file @
2b5b41bb
...
...
@@ -7,12 +7,12 @@ Linked fragment stage:
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 3
80
// Id's are bound by 3
78
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 16 41 90 37
6
EntryPoint Fragment 4 "main" 16 41 90 37
4
ExecutionMode 4 OriginLowerLeft
Source GLSL 450
Name 4 "main"
...
...
@@ -42,15 +42,8 @@ Linked fragment stage:
Name 343 "bn"
MemberName 343(bn) 0 "foo2a"
Name 345 "bi"
Name 347 "s1"
MemberName 347(s1) 0 "i"
MemberName 347(s1) 1 "f"
Name 348 "s2"
MemberName 348(s2) 0 "i"
MemberName 348(s2) 1 "f"
MemberName 348(s2) 2 "s1_1"
Name 376 "color"
Name 379 "foo1"
Name 374 "color"
Name 377 "foo1"
MemberDecorate 341(s1) 0 Offset 0
MemberDecorate 341(s1) 1 Offset 4
MemberDecorate 342(s2) 0 Offset 0
...
...
@@ -108,14 +101,12 @@ Linked fragment stage:
344: TypePointer Uniform 343(bn)
345(bi): 344(ptr) Variable Uniform
346: 6(int) Constant 0
347(s1): TypeStruct 6(int) 7(float)
348(s2): TypeStruct 6(int) 7(float) 347(s1)
349: TypePointer Uniform 342(s2)
372: 7(float) Constant 1090519040
375: TypePointer Output 14(fvec4)
376(color): 375(ptr) Variable Output
378: TypePointer UniformConstant 8(s1)
379(foo1): 378(ptr) Variable UniformConstant
347: TypePointer Uniform 342(s2)
370: 7(float) Constant 1090519040
373: TypePointer Output 14(fvec4)
374(color): 373(ptr) Variable Output
376: TypePointer UniformConstant 8(s1)
377(foo1): 376(ptr) Variable UniformConstant
4(main): 2 Function None 3
5: Label
13(a): 12(ptr) Variable Function
...
...
@@ -439,35 +430,35 @@ Linked fragment stage:
Store 82(v) 340
Branch 337
337: Label
3
50: 349
(ptr) AccessChain 345(bi) 346
3
51: 342(s2) Load 350
35
2
: 55(s2) Load 57(foo2a)
35
3: 6(int) CompositeExtract 351
0
35
4: 6(int) CompositeExtract 352
0
35
5: 61(bool) INotEqual 353 354
35
6: 7(float) CompositeExtract 351
1
35
7: 7(float) CompositeExtract 352
1
35
8: 61(bool) FOrdNotEqual 356 357
35
9: 61(bool) LogicalOr 355 358
3
60: 341(s1) CompositeExtract 351
2
3
61: 8(s1) CompositeExtract 352
2
36
2: 6(int) CompositeExtract 360
0
36
3: 6(int) CompositeExtract 361
0
36
4: 61(bool) INotEqual 362 363
36
5: 7(float) CompositeExtract 360
1
36
6: 7(float) CompositeExtract 361
1
36
7: 61(bool) FOrdNotEqual 365 366
36
8: 61(bool) LogicalOr 364 367
36
9: 61(bool) LogicalOr 359 368
SelectionMerge 3
71
None
BranchConditional 36
9 370 371
3
70
: Label
37
3
: 14(fvec4) Load 82(v)
37
4: 14(fvec4) VectorTimesScalar 373 372
Store 82(v) 37
4
Branch 3
71
3
71
: Label
37
7
: 14(fvec4) Load 82(v)
Store 37
6(color) 377
3
48: 347
(ptr) AccessChain 345(bi) 346
3
49: 342(s2) Load 348
35
0
: 55(s2) Load 57(foo2a)
35
1: 6(int) CompositeExtract 349
0
35
2: 6(int) CompositeExtract 350
0
35
3: 61(bool) INotEqual 351 352
35
4: 7(float) CompositeExtract 349
1
35
5: 7(float) CompositeExtract 350
1
35
6: 61(bool) FOrdNotEqual 354 355
35
7: 61(bool) LogicalOr 353 356
3
58: 341(s1) CompositeExtract 349
2
3
59: 8(s1) CompositeExtract 350
2
36
0: 6(int) CompositeExtract 358
0
36
1: 6(int) CompositeExtract 359
0
36
2: 61(bool) INotEqual 360 361
36
3: 7(float) CompositeExtract 358
1
36
4: 7(float) CompositeExtract 359
1
36
5: 61(bool) FOrdNotEqual 363 364
36
6: 61(bool) LogicalOr 362 365
36
7: 61(bool) LogicalOr 357 366
SelectionMerge 3
69
None
BranchConditional 36
7 368 369
3
68
: Label
37
1
: 14(fvec4) Load 82(v)
37
2: 14(fvec4) VectorTimesScalar 371 370
Store 82(v) 37
2
Branch 3
69
3
69
: Label
37
5
: 14(fvec4) Load 82(v)
Store 37
4(color) 375
Return
FunctionEnd
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment