rename RefreshDevice to GraphicsDevice

main
cosmonaut 2021-01-15 18:13:53 -08:00
parent e9dfdb0921
commit de32fe435c
12 changed files with 29 additions and 22 deletions

View File

@ -8,7 +8,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyBuffer;
public Buffer(
RefreshDevice device,
GraphicsDevice device,
Refresh.BufferUsageFlags usageFlags,
uint sizeInBytes
) : base(device)

View File

@ -13,7 +13,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyColorTarget;
public ColorTarget(RefreshDevice device, Refresh.SampleCount sampleCount, ref TextureSlice textureSlice) : base(device)
public ColorTarget(GraphicsDevice device, Refresh.SampleCount sampleCount, ref TextureSlice textureSlice) : base(device)
{
var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
Handle = Refresh.Refresh_CreateColorTarget(device.Handle, sampleCount, ref refreshTextureSlice);

View File

@ -6,11 +6,11 @@ namespace Campari
{
public struct CommandBuffer
{
public RefreshDevice Device { get; }
public GraphicsDevice Device { get; }
public IntPtr Handle { get; }
// called from RefreshDevice
internal CommandBuffer(RefreshDevice device, IntPtr handle)
internal CommandBuffer(GraphicsDevice device, IntPtr handle)
{
Device = device;
Handle = handle;

View File

@ -11,7 +11,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyDepthStencilTarget;
public DepthStencilTarget(RefreshDevice device, uint width, uint height, Refresh.DepthFormat depthFormat) : base(device)
public DepthStencilTarget(GraphicsDevice device, uint width, uint height, Refresh.DepthFormat depthFormat) : base(device)
{
Handle = Refresh.Refresh_CreateDepthStencilTarget(device.Handle, width, height, depthFormat);
Width = width;

View File

@ -8,7 +8,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyFramebuffer;
public unsafe Framebuffer(
RefreshDevice device,
GraphicsDevice device,
uint width,
uint height,
RenderPass renderPass,

View File

@ -6,16 +6,23 @@ using RefreshCS;
namespace Campari
{
public class RefreshDevice : IDisposable
public class GraphicsDevice : IDisposable
{
public IntPtr Handle { get; }
public bool IsDisposed { get; private set; }
public RefreshDevice(
Refresh.PresentationParameters presentationParameters,
public GraphicsDevice(
IntPtr deviceWindowHandle,
Refresh.PresentMode presentMode,
bool debugMode
) {
var presentationParameters = new Refresh.PresentationParameters
{
deviceWindowHandle = deviceWindowHandle,
presentMode = presentMode
};
Handle = Refresh.Refresh_CreateDevice(
ref presentationParameters,
Conversions.BoolToByte(debugMode)
@ -60,7 +67,7 @@ namespace Campari
}
// TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
~RefreshDevice()
~GraphicsDevice()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: false);

View File

@ -9,7 +9,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyGraphicsPipeline;
public unsafe GraphicsPipeline(
RefreshDevice device,
GraphicsDevice device,
ColorBlendState colorBlendState,
DepthStencilState depthStencilState,
ShaderStageState vertexShaderState,

View File

@ -6,13 +6,13 @@ namespace Campari
{
public abstract class GraphicsResource : IDisposable
{
public RefreshDevice Device { get; }
public GraphicsDevice Device { get; }
public IntPtr Handle { get; protected set; }
public bool IsDisposed { get; private set; }
protected abstract Action<IntPtr, IntPtr> QueueDestroyFunction { get; }
public GraphicsResource(RefreshDevice device)
public GraphicsResource(GraphicsDevice device)
{
Device = device;
}

View File

@ -8,7 +8,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyRenderPass;
public unsafe RenderPass(
RefreshDevice device,
GraphicsDevice device,
params Refresh.ColorTargetDescription[] colorTargetDescriptions
) : base(device)
{
@ -24,7 +24,7 @@ namespace Campari
}
public unsafe RenderPass(
RefreshDevice device,
GraphicsDevice device,
Refresh.DepthStencilTargetDescription depthStencilTargetDescription,
params Refresh.ColorTargetDescription[] colorTargetDescriptions
) : base(device)

View File

@ -8,7 +8,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroySampler;
public Sampler(
RefreshDevice device,
GraphicsDevice device,
ref SamplerState samplerState
) : base(device)
{

View File

@ -8,7 +8,7 @@ namespace Campari
{
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyShaderModule;
public unsafe ShaderModule(RefreshDevice device, FileInfo fileInfo) : base(device)
public unsafe ShaderModule(GraphicsDevice device, FileInfo fileInfo) : base(device)
{
fixed (uint* ptr = Bytecode.ReadBytecode(fileInfo))
{

View File

@ -12,7 +12,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyTexture;
public static Texture LoadPNG(RefreshDevice device, FileInfo fileInfo)
public static Texture LoadPNG(GraphicsDevice device, FileInfo fileInfo)
{
var pixels = Refresh.Refresh_Image_Load(
fileInfo.FullName,
@ -40,7 +40,7 @@ namespace Campari
}
public static Texture CreateTexture2D(
RefreshDevice device,
GraphicsDevice device,
uint width,
uint height,
Refresh.ColorFormat format,
@ -65,7 +65,7 @@ namespace Campari
}
public static Texture CreateTexture3D(
RefreshDevice device,
GraphicsDevice device,
uint width,
uint height,
uint depth,
@ -91,7 +91,7 @@ namespace Campari
}
public static Texture CreateTextureCube(
RefreshDevice device,
GraphicsDevice device,
uint size,
Refresh.ColorFormat format,
Refresh.TextureUsageFlags usageFlags,
@ -114,7 +114,7 @@ namespace Campari
return new Texture(device, ref textureCreateInfo);
}
public Texture(RefreshDevice device, ref Campari.TextureCreateInfo textureCreateInfo) : base(device)
public Texture(GraphicsDevice device, ref Campari.TextureCreateInfo textureCreateInfo) : base(device)
{
var refreshTextureCreateInfo = textureCreateInfo.ToRefreshTextureCreateInfo();