refactor built-in shader pipelines

refresh2
cosmonaut 2024-06-05 22:01:12 -07:00
parent 7386952974
commit ad025e1777
15 changed files with 31 additions and 62 deletions

View File

@ -25,20 +25,17 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\fullscreen.vert.refresh">
<LogicalName>MoonWorks.Graphics.StockShaders.Fullscreen.vert.refresh</LogicalName>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\fullscreen.vert.spv">
<LogicalName>MoonWorks.Graphics.StockShaders.Fullscreen.vert.spv</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\video_yuv2rgba.frag.refresh">
<LogicalName>MoonWorks.Graphics.StockShaders.VideoYUV2RGBA.frag.refresh</LogicalName>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\video_yuv2rgba.frag.spv">
<LogicalName>MoonWorks.Graphics.StockShaders.VideoYUV2RGBA.frag.spv</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\text_transform.vert.refresh">
<LogicalName>MoonWorks.Graphics.StockShaders.TextTransform.vert.refresh</LogicalName>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\text_transform.vert.spv">
<LogicalName>MoonWorks.Graphics.StockShaders.TextTransform.vert.spv</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\text_msdf.frag.refresh">
<LogicalName>MoonWorks.Graphics.StockShaders.TextMSDF.frag.refresh</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\blit.frag.refresh">
<LogicalName>MoonWorks.Graphics.StockShaders.Blit.frag.refresh</LogicalName>
<EmbeddedResource Include="src\Graphics\StockShaders\Binary\text_msdf.frag.spv">
<LogicalName>MoonWorks.Graphics.StockShaders.TextMSDF.frag.spv</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -67,7 +67,6 @@ namespace MoonWorks.Graphics
string textFragPath = Path.Combine(basePath, "text_msdf.frag.refresh");
string videoFragPath = Path.Combine(basePath, "video_yuv2rgba.frag.refresh");
string blitFragPath = Path.Combine(basePath, "blit.frag.refresh");
Shader fullscreenVertShader;
@ -75,7 +74,6 @@ namespace MoonWorks.Graphics
Shader textFragShader;
Shader videoFragShader;
Shader blitFragShader;
if (File.Exists(fullscreenVertPath))
{
@ -91,7 +89,7 @@ namespace MoonWorks.Graphics
{
// use defaults
var assembly = typeof(GraphicsDevice).Assembly;
using var vertStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.Fullscreen.vert.refresh");
using var vertStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.Fullscreen.vert.spv");
fullscreenVertShader = new Shader(
this,
vertStream,
@ -115,7 +113,7 @@ namespace MoonWorks.Graphics
{
// use defaults
var assembly = typeof(GraphicsDevice).Assembly;
using var fragStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.VideoYUV2RGBA.frag.refresh");
using var fragStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.VideoYUV2RGBA.frag.spv");
videoFragShader = new Shader(
this,
fragStream,
@ -148,8 +146,8 @@ namespace MoonWorks.Graphics
// use defaults
var assembly = typeof(GraphicsDevice).Assembly;
using var vertStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.TextTransform.vert.refresh");
using var fragStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.TextMSDF.frag.refresh");
using var vertStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.TextTransform.vert.spv");
using var fragStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.TextMSDF.frag.spv");
textVertShader = new Shader(
this,
@ -168,31 +166,6 @@ namespace MoonWorks.Graphics
);
}
if (File.Exists(blitFragPath))
{
blitFragShader = new Shader(
this,
blitFragPath,
"main",
ShaderStage.Fragment,
ShaderFormat.SECRET
);
}
else
{
// use defaults
var assembly = typeof(GraphicsDevice).Assembly;
using var fragStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.Blit.frag.refresh");
blitFragShader = new Shader(
this,
fragStream,
"main",
ShaderStage.Fragment,
ShaderFormat.SPIRV
);
}
VideoPipeline = new GraphicsPipeline(
this,
new GraphicsPipelineCreateInfo

Binary file not shown.

View File

@ -1,12 +0,0 @@
#version 450
layout (location = 0) in vec2 TexCoord;
layout (location = 0) out vec4 FragColor;
layout (binding = 0, set = 1) uniform sampler2D TexSampler;
void main()
{
FragColor = texture(TexSampler, TexCoord);
}

View File

@ -1,13 +1,13 @@
#version 450
layout(set = 1, binding = 0) uniform sampler2D msdf;
layout(location = 0) in vec2 inTexCoord;
layout(location = 1) in vec4 inColor;
layout(location = 0) out vec4 outColor;
layout(binding = 0, set = 3) uniform UBO
layout(set = 2, binding = 0) uniform sampler2D msdf;
layout(set = 3, binding = 0) uniform UBO
{
float pxRange;
} ubo;

View File

@ -7,7 +7,7 @@ layout(location = 2) in vec4 inColor;
layout(location = 0) out vec2 outTexCoord;
layout(location = 1) out vec4 outColor;
layout(binding = 0, set = 2) uniform UBO
layout(set = 1, binding = 0) uniform UBO
{
mat4 ViewProjection;
} ubo;

View File

@ -9,9 +9,9 @@ layout(location = 0) in vec2 TexCoord;
layout(location = 0) out vec4 FragColor;
layout(binding = 0, set = 1) uniform sampler2D YSampler;
layout(binding = 1, set = 1) uniform sampler2D USampler;
layout(binding = 2, set = 1) uniform sampler2D VSampler;
layout(set = 2, binding = 0) uniform sampler2D YSampler;
layout(set = 2, binding = 1) uniform sampler2D USampler;
layout(set = 2, binding = 2) uniform sampler2D VSampler;
/* More info about colorspace conversion:
* http://www.equasys.de/colorconversion.html

View File

@ -31,6 +31,8 @@ namespace MoonWorks
}
}
public string Title { get; private set;}
private bool IsDisposed;
private static Dictionary<uint, Window> idLookup = new Dictionary<uint, Window>();
@ -111,7 +113,7 @@ namespace MoonWorks
/// </summary>
/// <param name="width"></param>
/// <param name="height"></param>
public void SetWindowSize(uint width, uint height)
public void SetSize(uint width, uint height)
{
SDL.SDL_SetWindowSize(Handle, (int) width, (int) height);
Width = width;
@ -131,6 +133,15 @@ namespace MoonWorks
SDL.SDL_SetWindowPosition(Handle, x, y);
}
/// <summary>
/// Sets the window title.
/// </summary>
public void SetTitle(string title)
{
SDL.SDL_SetWindowTitle(Handle, title);
Title = title;
}
internal static Window Lookup(uint windowID)
{
return idLookup.ContainsKey(windowID) ? idLookup[windowID] : null;