Rendertarget inherits from texture

This commit is contained in:
Simon Lübeß
2022-05-04 14:53:31 +02:00
parent 9c93ccee47
commit 805423a64e
6 changed files with 25 additions and 39 deletions
+7 -18
View File
@@ -33,34 +33,23 @@ namespace GlitchyEngine.Renderer
}
}
public class RenderTarget2D : RefCounter
public class RenderTarget2D : Texture
{
private RenderTarget2DDescription _description;
public RenderTarget2DDescription Description => _description;
public uint32 Width => _description.Width;
public uint32 Height => _description.Height;
public override uint32 Width => _description.Width;
public override uint32 Height => _description.Height;
public override uint32 Depth => 1;
public override uint32 ArraySize => _description.ArraySize;
public override uint32 MipLevels => _description.MipLevels;
protected internal DepthStencilTarget _depthStenilTarget ~ _?.ReleaseRef();
// TODO: DepthStencilTarget is just a renderTarget
public DepthStencilTarget DepthStencilTarget => _depthStenilTarget;
protected SamplerState _samplerState ~ _?.ReleaseRef();
public SamplerState SamplerState
{
get => _samplerState;
set
{
if(_samplerState == value)
return;
SetReference!(_samplerState, value);
}
}
public this(RenderTarget2DDescription description)
{
Debug.Profiler.ProfileResourceFunction!();
+8 -8
View File
@@ -91,13 +91,13 @@ namespace GlitchyEngine.Renderer
FrontToBack
}
struct QueueQuad: this(Matrix Transform, ColorRGBA Color, Texture2D Texture, float Depth, Vector4 uvTransform) { }
struct QueueQuad: this(Matrix Transform, ColorRGBA Color, Texture Texture, float Depth, Vector4 uvTransform) { }
struct QueueCircle : QueueQuad
{
public float InnerRadius;
public this(Matrix Transform, ColorRGBA Color, Texture2D Texture, float Depth, Vector4 uvTransform, float innerRadius)
public this(Matrix Transform, ColorRGBA Color, Texture Texture, float Depth, Vector4 uvTransform, float innerRadius)
: base(Transform, Color, Texture, Depth, uvTransform)
{
InnerRadius = innerRadius;
@@ -472,7 +472,7 @@ namespace GlitchyEngine.Renderer
/// Adds a quad instance to the instance queue.
[Inline]
private static void QueueQuadInstance(Matrix transform, ColorRGBA color, Texture2D texture, float depth, Vector4 uvTransform)
private static void QueueQuadInstance(Matrix transform, ColorRGBA color, Texture texture, float depth, Vector4 uvTransform)
{
s_QuadinstanceQueue.Add(QueueQuad(transform, color, texture ?? s_whiteTexture, depth, uvTransform));
s_statistics.QuadCount++;
@@ -593,7 +593,7 @@ namespace GlitchyEngine.Renderer
if(s_QuadinstanceQueue.IsEmpty)
return;
Texture2D texture = s_QuadinstanceQueue[0].Texture;
Texture texture = s_QuadinstanceQueue[0].Texture;
s_currentEffect.SetTexture("Texture", texture);
s_setInstances = 0;
@@ -631,7 +631,7 @@ namespace GlitchyEngine.Renderer
if(s_circleInstanceQueue.IsEmpty)
return;
Texture2D texture = s_circleInstanceQueue[0].Texture;
Texture texture = s_circleInstanceQueue[0].Texture;
s_currentCircleEffect.SetTexture("Texture", texture);
s_setInstances = 0;
@@ -764,19 +764,19 @@ namespace GlitchyEngine.Renderer
// Textured Quad
public static void DrawQuad(Vector2 position, Vector2 size, float rotation, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
public static void DrawQuad(Vector2 position, Vector2 size, float rotation, Texture texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
{
DrawQuad(Vector3(position, 0.0f), size, rotation, texture, color, uvTransform);
}
public static void DrawQuad(Vector3 position, Vector2 size, float rotation, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
public static void DrawQuad(Vector3 position, Vector2 size, float rotation, Texture texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
{
Matrix transform = Calculate2DTransform(position, size, rotation);
DrawQuad(transform, texture, color, uvTransform);
}
public static void DrawQuad(Matrix transform, Texture2D texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
public static void DrawQuad(Matrix transform, Texture texture, ColorRGBA color = .White, Vector4 uvTransform = .(0, 0, 1, 1))
{
Debug.Profiler.ProfileRendererFunction!();
+2 -4
View File
@@ -17,10 +17,8 @@ namespace GlitchyEngine.Renderer
{
if(_samplerState == value)
return;
_samplerState?.ReleaseRef();
_samplerState = value;
_samplerState?.AddRef();
SetReference!(_samplerState, value);
}
}