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
228e964b
Commit
228e964b
authored
Aug 13, 2018
by
John Kessenich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPV: Correct SPIR-V operands for <id> versus immediate.
parent
72f8c690
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
16 deletions
+34
-16
SpvBuilder.cpp
SPIRV/SpvBuilder.cpp
+8
-8
SpvPostProcess.cpp
SPIRV/SpvPostProcess.cpp
+2
-2
spvIR.h
SPIRV/spvIR.h
+24
-6
No files found.
SPIRV/SpvBuilder.cpp
View file @
228e964b
...
...
@@ -509,7 +509,7 @@ Id Builder::getDerefTypeId(Id resultId) const
Id
typeId
=
getTypeId
(
resultId
);
assert
(
isPointerType
(
typeId
));
return
module
.
getInstruction
(
typeId
)
->
getI
mmediate
Operand
(
1
);
return
module
.
getInstruction
(
typeId
)
->
getI
d
Operand
(
1
);
}
Op
Builder
::
getMostBasicTypeClass
(
Id
typeId
)
const
...
...
@@ -553,7 +553,7 @@ int Builder::getNumTypeConstituents(Id typeId) const
return
instr
->
getImmediateOperand
(
1
);
case
OpTypeArray
:
{
Id
lengthId
=
instr
->
getI
mmediate
Operand
(
1
);
Id
lengthId
=
instr
->
getI
d
Operand
(
1
);
return
module
.
getInstruction
(
lengthId
)
->
getImmediateOperand
(
0
);
}
case
OpTypeStruct
:
...
...
@@ -1351,17 +1351,17 @@ void Builder::createNoResultOp(Op opCode, const std::vector<Id>& operands)
void
Builder
::
createControlBarrier
(
Scope
execution
,
Scope
memory
,
MemorySemanticsMask
semantics
)
{
Instruction
*
op
=
new
Instruction
(
OpControlBarrier
);
op
->
addI
mmediate
Operand
(
makeUintConstant
(
execution
));
op
->
addI
mmediate
Operand
(
makeUintConstant
(
memory
));
op
->
addI
mmediate
Operand
(
makeUintConstant
(
semantics
));
op
->
addI
d
Operand
(
makeUintConstant
(
execution
));
op
->
addI
d
Operand
(
makeUintConstant
(
memory
));
op
->
addI
d
Operand
(
makeUintConstant
(
semantics
));
buildPoint
->
addInstruction
(
std
::
unique_ptr
<
Instruction
>
(
op
));
}
void
Builder
::
createMemoryBarrier
(
unsigned
executionScope
,
unsigned
memorySemantics
)
{
Instruction
*
op
=
new
Instruction
(
OpMemoryBarrier
);
op
->
addI
mmediate
Operand
(
makeUintConstant
(
executionScope
));
op
->
addI
mmediate
Operand
(
makeUintConstant
(
memorySemantics
));
op
->
addI
d
Operand
(
makeUintConstant
(
executionScope
));
op
->
addI
d
Operand
(
makeUintConstant
(
memorySemantics
));
buildPoint
->
addInstruction
(
std
::
unique_ptr
<
Instruction
>
(
op
));
}
...
...
@@ -2026,7 +2026,7 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
int
numRows
=
getTypeNumRows
(
resultTypeId
);
Instruction
*
instr
=
module
.
getInstruction
(
componentTypeId
);
Id
bitCount
=
instr
->
getId
Operand
(
0
);
unsigned
bitCount
=
instr
->
getImmediate
Operand
(
0
);
// Optimize matrix constructed from a bigger matrix
if
(
isMatrix
(
sources
[
0
])
&&
getNumColumns
(
sources
[
0
])
>=
numCols
&&
getNumRows
(
sources
[
0
])
>=
numRows
)
{
...
...
SPIRV/SpvPostProcess.cpp
View file @
228e964b
...
...
@@ -61,13 +61,13 @@ namespace spv {
namespace
spv
{
// Called for each instruction in a block.
// Called for each instruction
that resides
in a block.
void
Builder
::
postProcess
(
Instruction
&
inst
)
{
// Add capabilities based simply on the opcode.
switch
(
inst
.
getOpCode
())
{
case
OpExtInst
:
switch
(
inst
.
getI
d
Operand
(
1
))
{
switch
(
inst
.
getI
mmediate
Operand
(
1
))
{
case
GLSLstd450InterpolateAtCentroid
:
case
GLSLstd450InterpolateAtSample
:
case
GLSLstd450InterpolateAtOffset
:
...
...
SPIRV/spvIR.h
View file @
228e964b
...
...
@@ -88,8 +88,14 @@ public:
Instruction
(
Id
resultId
,
Id
typeId
,
Op
opCode
)
:
resultId
(
resultId
),
typeId
(
typeId
),
opCode
(
opCode
),
block
(
nullptr
)
{
}
explicit
Instruction
(
Op
opCode
)
:
resultId
(
NoResult
),
typeId
(
NoType
),
opCode
(
opCode
),
block
(
nullptr
)
{
}
virtual
~
Instruction
()
{}
void
addIdOperand
(
Id
id
)
{
operands
.
push_back
(
id
);
}
void
addImmediateOperand
(
unsigned
int
immediate
)
{
operands
.
push_back
(
immediate
);
}
void
addIdOperand
(
Id
id
)
{
operands
.
push_back
(
id
);
idOperand
.
push_back
(
true
);
}
void
addImmediateOperand
(
unsigned
int
immediate
)
{
operands
.
push_back
(
immediate
);
idOperand
.
push_back
(
false
);
}
void
addStringOperand
(
const
char
*
str
)
{
unsigned
int
word
;
...
...
@@ -116,14 +122,25 @@ public:
addImmediateOperand
(
word
);
}
}
bool
isIdOperand
(
int
op
)
{
return
idOperand
[
op
];
}
void
setBlock
(
Block
*
b
)
{
block
=
b
;
}
Block
*
getBlock
()
const
{
return
block
;
}
Op
getOpCode
()
const
{
return
opCode
;
}
int
getNumOperands
()
const
{
return
(
int
)
operands
.
size
();
}
int
getNumOperands
()
const
{
assert
(
operands
.
size
()
==
idOperand
.
size
());
return
(
int
)
operands
.
size
();
}
Id
getResultId
()
const
{
return
resultId
;
}
Id
getTypeId
()
const
{
return
typeId
;
}
Id
getIdOperand
(
int
op
)
const
{
return
operands
[
op
];
}
unsigned
int
getImmediateOperand
(
int
op
)
const
{
return
operands
[
op
];
}
Id
getIdOperand
(
int
op
)
const
{
assert
(
idOperand
[
op
]);
return
operands
[
op
];
}
unsigned
int
getImmediateOperand
(
int
op
)
const
{
assert
(
!
idOperand
[
op
]);
return
operands
[
op
];
}
// Write out the binary form.
void
dump
(
std
::
vector
<
unsigned
int
>&
out
)
const
...
...
@@ -153,7 +170,8 @@ protected:
Id
resultId
;
Id
typeId
;
Op
opCode
;
std
::
vector
<
Id
>
operands
;
std
::
vector
<
Id
>
operands
;
// operands, both <id> and immediates (both are unsigned int)
std
::
vector
<
bool
>
idOperand
;
// true for operands that are <id>, false for immediates
Block
*
block
;
};
...
...
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