forked from MoonsideGames/MoonWorks
Compare commits
No commits in common. "f3c74aa72acbbc0f1e99818f8cc2ed1f350e6ceb" and "030745361b5c517b234a1ea80e104468920b529e" have entirely different histories.
f3c74aa72a
...
030745361b
|
@ -24,4 +24,13 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="src\Video\Shaders\Compiled\FullscreenVert.spv">
|
||||
<LogicalName>MoonWorks.Shaders.FullscreenVert.spv</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="src\Video\Shaders\Compiled\YUV2RGBAFrag.spv">
|
||||
<LogicalName>MoonWorks.Shaders.YUV2RGBAFrag.spv</LogicalName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace MoonWorks.Graphics
|
|||
public SDL2.SDL.SDL_WindowFlags WindowFlags => (SDL2.SDL.SDL_WindowFlags) windowFlags;
|
||||
|
||||
// Built-in video pipeline
|
||||
private ShaderModule VideoVertexShader { get; }
|
||||
private ShaderModule VideoFragmentShader { get; }
|
||||
internal GraphicsPipeline VideoPipeline { get; }
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
@ -23,7 +25,8 @@ namespace MoonWorks.Graphics
|
|||
public GraphicsDevice(
|
||||
Backend preferredBackend,
|
||||
bool debugMode
|
||||
) {
|
||||
)
|
||||
{
|
||||
Backend = (Backend) Refresh.Refresh_SelectBackend((Refresh.Backend) preferredBackend, out windowFlags);
|
||||
|
||||
if (Backend == Backend.Invalid)
|
||||
|
@ -35,43 +38,25 @@ namespace MoonWorks.Graphics
|
|||
Conversions.BoolToByte(debugMode)
|
||||
);
|
||||
|
||||
// Check for optional video shaders
|
||||
string basePath = SDL2.SDL.SDL_GetBasePath();
|
||||
string videoVertPath = Path.Combine(basePath, "Fullscreen.refresh");
|
||||
string videoFragPath = Path.Combine(basePath, "YUV2RGBA.refresh");
|
||||
if (File.Exists(videoVertPath) && File.Exists(videoFragPath))
|
||||
{
|
||||
ShaderModule videoVertShader = new ShaderModule(this, videoVertPath);
|
||||
ShaderModule videoFragShader = new ShaderModule(this, videoFragPath);
|
||||
VideoVertexShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.FullscreenVert.spv"));
|
||||
VideoFragmentShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.YUV2RGBAFrag.spv"));
|
||||
|
||||
VideoPipeline = new GraphicsPipeline(
|
||||
this,
|
||||
new GraphicsPipelineCreateInfo
|
||||
{
|
||||
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
|
||||
new ColorAttachmentDescription(
|
||||
TextureFormat.R8G8B8A8,
|
||||
ColorAttachmentBlendState.None
|
||||
)
|
||||
),
|
||||
DepthStencilState = DepthStencilState.Disable,
|
||||
VertexShaderInfo = GraphicsShaderInfo.Create(
|
||||
videoVertShader,
|
||||
"main",
|
||||
0
|
||||
),
|
||||
FragmentShaderInfo = GraphicsShaderInfo.Create(
|
||||
videoFragShader,
|
||||
"main",
|
||||
3
|
||||
),
|
||||
VertexInputState = VertexInputState.Empty,
|
||||
RasterizerState = RasterizerState.CCW_CullNone,
|
||||
PrimitiveType = PrimitiveType.TriangleList,
|
||||
MultisampleState = MultisampleState.None
|
||||
}
|
||||
);
|
||||
}
|
||||
VideoPipeline = new GraphicsPipeline(
|
||||
this,
|
||||
new GraphicsPipelineCreateInfo
|
||||
{
|
||||
AttachmentInfo = new GraphicsPipelineAttachmentInfo(
|
||||
new ColorAttachmentDescription(TextureFormat.R8G8B8A8, ColorAttachmentBlendState.None)
|
||||
),
|
||||
DepthStencilState = DepthStencilState.Disable,
|
||||
VertexShaderInfo = GraphicsShaderInfo.Create(VideoVertexShader, "main", 0),
|
||||
FragmentShaderInfo = GraphicsShaderInfo.Create(VideoFragmentShader, "main", 3),
|
||||
VertexInputState = VertexInputState.Empty,
|
||||
RasterizerState = RasterizerState.CCW_CullNone,
|
||||
PrimitiveType = PrimitiveType.TriangleList,
|
||||
MultisampleState = MultisampleState.None
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public bool ClaimWindow(Window window, PresentMode presentMode)
|
||||
|
@ -117,7 +102,7 @@ namespace MoonWorks.Graphics
|
|||
|
||||
public CommandBuffer AcquireCommandBuffer()
|
||||
{
|
||||
return new CommandBuffer(this, Refresh.Refresh_AcquireCommandBuffer(Handle));
|
||||
return new CommandBuffer(this, Refresh.Refresh_AcquireCommandBuffer(Handle, 0));
|
||||
}
|
||||
|
||||
public unsafe void Submit(CommandBuffer commandBuffer)
|
||||
|
@ -229,6 +214,11 @@ namespace MoonWorks.Graphics
|
|||
}
|
||||
}
|
||||
|
||||
private static Stream GetEmbeddedResource(string name)
|
||||
{
|
||||
return typeof(GraphicsDevice).Assembly.GetManifestResourceStream(name);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!IsDisposed)
|
||||
|
|
|
@ -5,7 +5,7 @@ using System.IO;
|
|||
namespace MoonWorks.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// Shader modules expect input in Refresh bytecode format.
|
||||
/// Shader modules expect input in SPIR-V bytecode format.
|
||||
/// </summary>
|
||||
public class ShaderModule : GraphicsResource
|
||||
{
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -50,11 +50,6 @@ namespace MoonWorks.Video
|
|||
public VideoPlayer(GraphicsDevice graphicsDevice, AudioDevice audioDevice)
|
||||
{
|
||||
GraphicsDevice = graphicsDevice;
|
||||
if (GraphicsDevice.VideoPipeline == null)
|
||||
{
|
||||
throw new InvalidOperationException("Missing video shaders!");
|
||||
}
|
||||
|
||||
AudioDevice = audioDevice;
|
||||
LinearSampler = new Sampler(graphicsDevice, SamplerCreateInfo.LinearClamp);
|
||||
|
||||
|
|
Loading…
Reference in New Issue