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
...
@@ -1570,7 +1570,12 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
spvType
=
builder
.
makeFloatType
(
64
);
spvType
=
builder
.
makeFloatType
(
64
);
break
;
break
;
case
glslang
:
:
EbtBool
:
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
;
break
;
case
glslang
:
:
EbtInt
:
case
glslang
:
:
EbtInt
:
spvType
=
builder
.
makeIntType
(
32
);
spvType
=
builder
.
makeIntType
(
32
);
...
@@ -1764,9 +1769,21 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
...
@@ -1764,9 +1769,21 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
return
spvType
;
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
)
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
// Decide whether or not this type should be
...
...
SPIRV/SpvBuilder.cpp
View file @
2b5b41bb
...
@@ -1990,6 +1990,39 @@ Id Builder::accessChainGetLValue()
...
@@ -1990,6 +1990,39 @@ Id Builder::accessChainGetLValue()
return
lvalue
;
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
void
Builder
::
dump
(
std
::
vector
<
unsigned
int
>&
out
)
const
{
{
// Header, before first instructions:
// Header, before first instructions:
...
...
SPIRV/SpvBuilder.h
View file @
2b5b41bb
...
@@ -506,6 +506,10 @@ public:
...
@@ -506,6 +506,10 @@ public:
// get the direct pointer for an l-value
// get the direct pointer for an l-value
Id
accessChainGetLValue
();
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
dump
(
std
::
vector
<
unsigned
int
>&
)
const
;
void
createBranch
(
Block
*
block
);
void
createBranch
(
Block
*
block
);
...
...
SPIRV/spirv.hpp
View file @
2b5b41bb
...
@@ -39,8 +39,8 @@
...
@@ -39,8 +39,8 @@
// "Mask" in their name, and a parallel enum that has the shift
// "Mask" in their name, and a parallel enum that has the shift
// amount (1 << x) for each corresponding enumerant.
// amount (1 << x) for each corresponding enumerant.
#ifndef spirv_H
#ifndef spirv_H
PP
#define spirv_H
#define spirv_H
PP
namespace
spv
{
namespace
spv
{
...
@@ -874,5 +874,4 @@ inline KernelProfilingInfoMask operator|(KernelProfilingInfoMask a, KernelProfil
...
@@ -874,5 +874,4 @@ inline KernelProfilingInfoMask operator|(KernelProfilingInfoMask a, KernelProfil
}
// end namespace spv
}
// 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:
...
@@ -7,12 +7,12 @@ Linked fragment stage:
// Module Version 10000
// Module Version 10000
// Generated by (magic number): 80001
// Generated by (magic number): 80001
// Id's are bound by 3
80
// Id's are bound by 3
78
Capability Shader
Capability Shader
1: ExtInstImport "GLSL.std.450"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 16 41 90 37
6
EntryPoint Fragment 4 "main" 16 41 90 37
4
ExecutionMode 4 OriginLowerLeft
ExecutionMode 4 OriginLowerLeft
Source GLSL 450
Source GLSL 450
Name 4 "main"
Name 4 "main"
...
@@ -42,15 +42,8 @@ Linked fragment stage:
...
@@ -42,15 +42,8 @@ Linked fragment stage:
Name 343 "bn"
Name 343 "bn"
MemberName 343(bn) 0 "foo2a"
MemberName 343(bn) 0 "foo2a"
Name 345 "bi"
Name 345 "bi"
Name 347 "s1"
Name 374 "color"
MemberName 347(s1) 0 "i"
Name 377 "foo1"
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"
MemberDecorate 341(s1) 0 Offset 0
MemberDecorate 341(s1) 0 Offset 0
MemberDecorate 341(s1) 1 Offset 4
MemberDecorate 341(s1) 1 Offset 4
MemberDecorate 342(s2) 0 Offset 0
MemberDecorate 342(s2) 0 Offset 0
...
@@ -108,14 +101,12 @@ Linked fragment stage:
...
@@ -108,14 +101,12 @@ Linked fragment stage:
344: TypePointer Uniform 343(bn)
344: TypePointer Uniform 343(bn)
345(bi): 344(ptr) Variable Uniform
345(bi): 344(ptr) Variable Uniform
346: 6(int) Constant 0
346: 6(int) Constant 0
347(s1): TypeStruct 6(int) 7(float)
347: TypePointer Uniform 342(s2)
348(s2): TypeStruct 6(int) 7(float) 347(s1)
370: 7(float) Constant 1090519040
349: TypePointer Uniform 342(s2)
373: TypePointer Output 14(fvec4)
372: 7(float) Constant 1090519040
374(color): 373(ptr) Variable Output
375: TypePointer Output 14(fvec4)
376: TypePointer UniformConstant 8(s1)
376(color): 375(ptr) Variable Output
377(foo1): 376(ptr) Variable UniformConstant
378: TypePointer UniformConstant 8(s1)
379(foo1): 378(ptr) Variable UniformConstant
4(main): 2 Function None 3
4(main): 2 Function None 3
5: Label
5: Label
13(a): 12(ptr) Variable Function
13(a): 12(ptr) Variable Function
...
@@ -439,35 +430,35 @@ Linked fragment stage:
...
@@ -439,35 +430,35 @@ Linked fragment stage:
Store 82(v) 340
Store 82(v) 340
Branch 337
Branch 337
337: Label
337: Label
3
50: 349
(ptr) AccessChain 345(bi) 346
3
48: 347
(ptr) AccessChain 345(bi) 346
3
51: 342(s2) Load 350
3
49: 342(s2) Load 348
35
2
: 55(s2) Load 57(foo2a)
35
0
: 55(s2) Load 57(foo2a)
35
3: 6(int) CompositeExtract 351
0
35
1: 6(int) CompositeExtract 349
0
35
4: 6(int) CompositeExtract 352
0
35
2: 6(int) CompositeExtract 350
0
35
5: 61(bool) INotEqual 353 354
35
3: 61(bool) INotEqual 351 352
35
6: 7(float) CompositeExtract 351
1
35
4: 7(float) CompositeExtract 349
1
35
7: 7(float) CompositeExtract 352
1
35
5: 7(float) CompositeExtract 350
1
35
8: 61(bool) FOrdNotEqual 356 357
35
6: 61(bool) FOrdNotEqual 354 355
35
9: 61(bool) LogicalOr 355 358
35
7: 61(bool) LogicalOr 353 356
3
60: 341(s1) CompositeExtract 351
2
3
58: 341(s1) CompositeExtract 349
2
3
61: 8(s1) CompositeExtract 352
2
3
59: 8(s1) CompositeExtract 350
2
36
2: 6(int) CompositeExtract 360
0
36
0: 6(int) CompositeExtract 358
0
36
3: 6(int) CompositeExtract 361
0
36
1: 6(int) CompositeExtract 359
0
36
4: 61(bool) INotEqual 362 363
36
2: 61(bool) INotEqual 360 361
36
5: 7(float) CompositeExtract 360
1
36
3: 7(float) CompositeExtract 358
1
36
6: 7(float) CompositeExtract 361
1
36
4: 7(float) CompositeExtract 359
1
36
7: 61(bool) FOrdNotEqual 365 366
36
5: 61(bool) FOrdNotEqual 363 364
36
8: 61(bool) LogicalOr 364 367
36
6: 61(bool) LogicalOr 362 365
36
9: 61(bool) LogicalOr 359 368
36
7: 61(bool) LogicalOr 357 366
SelectionMerge 3
71
None
SelectionMerge 3
69
None
BranchConditional 36
9 370 371
BranchConditional 36
7 368 369
3
70
: Label
3
68
: Label
37
3
: 14(fvec4) Load 82(v)
37
1
: 14(fvec4) Load 82(v)
37
4: 14(fvec4) VectorTimesScalar 373 372
37
2: 14(fvec4) VectorTimesScalar 371 370
Store 82(v) 37
4
Store 82(v) 37
2
Branch 3
71
Branch 3
69
3
71
: Label
3
69
: Label
37
7
: 14(fvec4) Load 82(v)
37
5
: 14(fvec4) Load 82(v)
Store 37
6(color) 377
Store 37
4(color) 375
Return
Return
FunctionEnd
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