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; protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyBuffer;
public Buffer( public Buffer(
RefreshDevice device, GraphicsDevice device,
Refresh.BufferUsageFlags usageFlags, Refresh.BufferUsageFlags usageFlags,
uint sizeInBytes uint sizeInBytes
) : base(device) ) : base(device)

View File

@ -13,7 +13,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyColorTarget; 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(); var refreshTextureSlice = textureSlice.ToRefreshTextureSlice();
Handle = Refresh.Refresh_CreateColorTarget(device.Handle, sampleCount, ref refreshTextureSlice); Handle = Refresh.Refresh_CreateColorTarget(device.Handle, sampleCount, ref refreshTextureSlice);

View File

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

View File

@ -11,7 +11,7 @@ namespace Campari
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyDepthStencilTarget; 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); Handle = Refresh.Refresh_CreateDepthStencilTarget(device.Handle, width, height, depthFormat);
Width = width; Width = width;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@ namespace Campari
{ {
protected override Action<IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyShaderModule; 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)) fixed (uint* ptr = Bytecode.ReadBytecode(fileInfo))
{ {

View File

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