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
c4372e43
Unverified
Commit
c4372e43
authored
Nov 28, 2017
by
John Kessenich
Committed by
GitHub
Nov 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1167 from LoopDawg/matmul-truncate-mxm
HLSL: add implicit mat*mat truncations
parents
72cddd01
cee29b04
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
hlsl.mul-truncate.frag.out
Test/baseResults/hlsl.mul-truncate.frag.out
+0
-0
hlsl.mul-truncate.frag
Test/hlsl.mul-truncate.frag
+7
-6
hlslParseHelper.cpp
hlsl/hlslParseHelper.cpp
+15
-4
No files found.
Test/baseResults/hlsl.mul-truncate.frag.out
View file @
c4372e43
This diff is collapsed.
Click to expand it.
Test/hlsl.mul-truncate.frag
View file @
c4372e43
...
...
@@ -6,6 +6,7 @@ cbuffer Matrix
float4x4
m44
;
float4x3
m43
;
float3x4
m34
;
float3x3
m33
;
float2x4
m24
;
float4x2
m42
;
float4
v4
;
...
...
@@ -27,11 +28,11 @@ float4 main() : SV_Target0
float4
r20
=
mul
(
m44
,
v3
);
// float4 = float4x4 * float3; // clamp mat to float4x3;
float4
r21
=
mul
(
m43
,
v4
);
// truncate vector to vec3
//
//
m*m
//
float2x3 r30 = mul(m24, m33); // float2x3 = float2x4 * float3x3;
//
float3x4 r31 = mul(m33, m24); // float3x4 = float3x3 * float2x4;
//
float3x2 r32 = mul(m33, m42); // float3x2 = float3x3 * float4x2;
//
float4x3 r33 = mul(m42, m33); // float4x3 = float4x2 * float3x3;
// m*m
float2x3
r30
=
mul
(
m24
,
m33
);
// float2x3 = float2x4 * float3x3;
float3x4
r31
=
mul
(
m33
,
m24
);
// float3x4 = float3x3 * float2x4;
float3x2
r32
=
mul
(
m33
,
m42
);
// float3x2 = float3x3 * float4x2;
float4x3
r33
=
mul
(
m42
,
m33
);
// float4x3 = float4x2 * float3x3;
return
r10
+
r11
+
r20
+
r21
+
r00
+
r01
;
//
+ r30[0].x + r31[0] + r32[0].x + transpose(r33)[0];
return
r10
+
r11
+
r20
+
r21
+
r00
+
r01
+
r30
[
0
].
x
+
r31
[
0
]
+
r32
[
0
].
x
+
transpose
(
r33
)[
0
];
}
hlsl/hlslParseHelper.cpp
View file @
c4372e43
...
...
@@ -5178,7 +5178,7 @@ void HlslParseContext::pushFrontArguments(TIntermTyped* front, TIntermTyped*& ar
//
// HLSL allows mismatched dimensions on vec*mat, mat*vec, vec*vec, and mat*mat. This is a
// situation not well suited to resolution in intrinsic selection, but we can do so here, since we
// can look at both arguments insert explicit shape changes
here,
if required.
// can look at both arguments insert explicit shape changes if required.
//
void
HlslParseContext
::
addGenMulArgumentConversion
(
const
TSourceLoc
&
loc
,
TFunction
&
call
,
TIntermTyped
*&
args
)
{
...
...
@@ -5224,12 +5224,23 @@ void HlslParseContext::addGenMulArgumentConversion(const TSourceLoc& loc, TFunct
arg1
=
addConstructor
(
loc
,
arg1
,
truncType
);
}
}
else
if
(
arg0
->
isMatrix
()
&&
arg1
->
isMatrix
())
{
// mat * mat
// mat * mat: we clamp the smaller inner dimension to match the other matrix size.
// Remember, HLSL Mrc = GLSL/SPIRV Mcr.
if
(
arg0
->
getMatrixRows
()
>
arg1
->
getMatrixCols
())
{
const
TType
truncType
(
arg0
->
getBasicType
(),
arg0
->
getQualifier
().
storage
,
arg0
->
getQualifier
().
precision
,
0
,
arg0
->
getMatrixCols
(),
arg1
->
getMatrixCols
());
arg0
=
addConstructor
(
loc
,
arg0
,
truncType
);
}
else
if
(
arg0
->
getMatrixRows
()
<
arg1
->
getMatrixCols
())
{
const
TType
truncType
(
arg1
->
getBasicType
(),
arg1
->
getQualifier
().
storage
,
arg1
->
getQualifier
().
precision
,
0
,
arg0
->
getMatrixRows
(),
arg1
->
getMatrixRows
());
arg1
=
addConstructor
(
loc
,
arg1
,
truncType
);
}
}
else
{
// It's something with scalars: we'll just leave it alone.
// It's something with scalars: we'll just leave it alone. Function selection will handle it
// downstream.
}
// Put arguments back.
// Put arguments back.
(They might be unchanged, in which case this is harmless).
argAggregate
->
getSequence
()[
0
]
=
arg0
;
argAggregate
->
getSequence
()[
1
]
=
arg1
;
...
...
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