forked from gfx-rs/naga
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hlsl-out: Add support for push constants (gfx-rs#2005)
Push constants need to be configured by the consumer which must pass the bind target of the constant buffer used for the push constants.
- Loading branch information
Showing
9 changed files
with
155 additions
and
52 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#version 320 es | ||
|
||
precision highp float; | ||
precision highp int; | ||
|
||
struct PushConstants { | ||
float multiplier; | ||
}; | ||
struct FragmentIn { | ||
vec4 color; | ||
}; | ||
uniform PushConstants pc; | ||
|
||
layout(location = 0) in vec2 _p2vs_location0; | ||
|
||
void main() { | ||
vec2 pos = _p2vs_location0; | ||
uint vi = uint(gl_VertexID); | ||
float _e5 = pc.multiplier; | ||
gl_Position = vec4(((float(vi) * _e5) * pos), 0.0, 1.0); | ||
return; | ||
} | ||
|
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,33 @@ | ||
struct NagaConstants { | ||
int base_vertex; | ||
int base_instance; | ||
uint other; | ||
}; | ||
ConstantBuffer<NagaConstants> _NagaConstants: register(b0, space1); | ||
|
||
struct PushConstants { | ||
float multiplier; | ||
}; | ||
|
||
struct FragmentIn { | ||
float4 color : LOC0; | ||
}; | ||
|
||
ConstantBuffer<PushConstants> pc: register(b0); | ||
|
||
struct FragmentInput_main { | ||
float4 color : LOC0; | ||
}; | ||
|
||
float4 vert_main(float2 pos : LOC0, uint vi : SV_VertexID) : SV_Position | ||
{ | ||
float _expr5 = pc.multiplier; | ||
return float4(((float((_NagaConstants.base_vertex + vi)) * _expr5) * pos), 0.0, 1.0); | ||
} | ||
|
||
float4 main(FragmentInput_main fragmentinput_main) : SV_Target0 | ||
{ | ||
FragmentIn in_ = { fragmentinput_main.color }; | ||
float _expr4 = pc.multiplier; | ||
return (in_.color * _expr4); | ||
} |
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,3 @@ | ||
vertex=(vert_main:vs_5_1 ) | ||
fragment=(main:ps_5_1 ) | ||
compute=() |
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