-
Notifications
You must be signed in to change notification settings - Fork 685
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call ctor function for static globals in patch constant function. (#3122
) * Call ctor function for static globals in patch constant function. * Also copy static globals which has const initialize value at beginning of patch constant.
- Loading branch information
1 parent
b3df129
commit 4446237
Showing
5 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tools/clang/test/HLSLFileCheck/shader_targets/hull/static_res_in_patch_constant_func.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// RUN: %dxc -E main -T hs_6_0 %s 2>&1 | FileCheck %s | ||
|
||
// Make sure generated buffer load for static buffer used in patch constant function. | ||
// CHECK:call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, | ||
|
||
struct HSPerPatchData | ||
{ | ||
float edges[3] : SV_TessFactor; | ||
float inside : SV_InsideTessFactor; | ||
}; | ||
|
||
Buffer<float> buf; | ||
|
||
const static Buffer<float> static_buf = buf; | ||
|
||
HSPerPatchData HSPerPatchFunc() | ||
{ | ||
HSPerPatchData d; | ||
|
||
d.edges[0] = -5; | ||
d.edges[1] = -6; | ||
d.edges[2] = -7; | ||
d.inside = static_buf[0]; | ||
|
||
return d; | ||
} | ||
|
||
|
||
|
||
// hull per-control point shader | ||
[domain("tri")] | ||
[partitioning("fractional_odd")] | ||
[outputtopology("triangle_cw")] | ||
[patchconstantfunc("HSPerPatchFunc")] | ||
[outputcontrolpoints(3)] | ||
void main( const uint id : SV_OutputControlPointID ) | ||
{ | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
tools/clang/test/HLSLFileCheck/shader_targets/hull/static_res_in_patch_constant_func2.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// RUN: %dxc -E main -T hs_6_0 %s 2>&1 | FileCheck %s | ||
|
||
// Make sure @sf is restored to original value in patch constant function. | ||
// CHECK:define void @"\01?HSPerPatchFunc@@YA?AUHSPerPatchData@@XZ"() { | ||
// CHECK:store float 3.000000e+00, float* @sf, align 4 | ||
// CHECK-NEXT:call void @dx.op.storePatchConstant.f32 | ||
// CHECK-NEXT:call void @dx.op.storePatchConstant.f32 | ||
// CHECK-NEXT:call void @dx.op.storePatchConstant.f32 | ||
// CHECK-NEXT:load float, float* @sf, align 4 | ||
// CHECK-NEXT:call void @dx.op.storePatchConstant.f32 | ||
struct HSPerPatchData | ||
{ | ||
float edges[3] : SV_TessFactor; | ||
float inside : SV_InsideTessFactor; | ||
}; | ||
|
||
static float sf = 3; | ||
|
||
HSPerPatchData HSPerPatchFunc() | ||
{ | ||
HSPerPatchData d; | ||
|
||
d.edges[0] = -5; | ||
d.edges[1] = -6; | ||
d.edges[2] = -7; | ||
d.inside = sf; | ||
|
||
return d; | ||
} | ||
|
||
|
||
|
||
// hull per-control point shader | ||
[domain("tri")] | ||
[partitioning("fractional_odd")] | ||
[outputtopology("triangle_cw")] | ||
[patchconstantfunc("HSPerPatchFunc")] | ||
[outputcontrolpoints(3)] | ||
void main( const uint id : SV_OutputControlPointID ) | ||
{ | ||
sf = 0; | ||
} |