mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-06 05:01:53 +00:00
Added support for Cube Textures, Improved dds import (and textures in general), Texture refactoring and DX11 DeviceContext synchronization
This commit is contained in:
@@ -30,11 +30,6 @@ namespace GlitchyEngine.Renderer
|
||||
public abstract uint32 MipLevels {get;}
|
||||
|
||||
public abstract TextureViewBinding GetViewBinding();
|
||||
|
||||
/// Very dirtily swaps the internals with the given texture.
|
||||
/// TODO: Please do this differently!!!!!!!!!!!!!!!!!!!!!!
|
||||
/// This is for texture hot reloading POC, I know... it's bad...
|
||||
protected internal abstract void SneakySwappyTexture(Texture otherTexture);
|
||||
}
|
||||
|
||||
public struct Texture2DDesc
|
||||
@@ -69,17 +64,6 @@ namespace GlitchyEngine.Renderer
|
||||
//public override extern uint32 ArraySize {get;}
|
||||
//public override extern uint32 MipLevels {get;}
|
||||
|
||||
// TODO: remove
|
||||
private this(Stream data)
|
||||
{
|
||||
LoadDds(data);
|
||||
}
|
||||
|
||||
protected void LoadDds(Stream stream)
|
||||
{
|
||||
LoadDdsPlatform(stream);
|
||||
}
|
||||
|
||||
public this(Texture2DDesc desc)
|
||||
{
|
||||
PrepareTexturePlatform(desc, false);
|
||||
@@ -100,8 +84,6 @@ namespace GlitchyEngine.Renderer
|
||||
uint32 mipLevels = 1, uint32 arraySize = 1, Usage usage = .Default, CPUAccessFlags cpuAccess = .None
|
||||
*/
|
||||
|
||||
protected extern void LoadDdsPlatform(Stream stream);
|
||||
|
||||
protected extern void CreateTexturePlatform(Texture2DDesc desc, bool isRenderTarget, void* data, uint32 linePitch);
|
||||
|
||||
/**
|
||||
@@ -130,17 +112,16 @@ namespace GlitchyEngine.Renderer
|
||||
}
|
||||
|
||||
protected extern TextureViewBinding PlatformGetViewBinding();
|
||||
}
|
||||
|
||||
protected internal override void SneakySwappyTexture(Texture otherTexture)
|
||||
{
|
||||
Log.EngineLogger.AssertDebug(otherTexture is Texture2D, "Swapping texture must be a Texture2D!");
|
||||
|
||||
SamplerState = otherTexture.SamplerState;
|
||||
|
||||
PlatformSneakySwappyTexture(otherTexture as Texture2D);
|
||||
}
|
||||
|
||||
protected extern void PlatformSneakySwappyTexture(Texture2D otherTexture);
|
||||
public enum TextureCubeFace
|
||||
{
|
||||
PositiveX = 0,
|
||||
NegativeX = 1,
|
||||
PositiveY = 2,
|
||||
NegativeY = 3,
|
||||
PositiveZ = 4,
|
||||
NegativeZ = 5,
|
||||
}
|
||||
|
||||
public class TextureCube : Texture
|
||||
@@ -152,24 +133,48 @@ namespace GlitchyEngine.Renderer
|
||||
public override uint32 Depth => 1;
|
||||
// public override extern uint32 ArraySize {get;}
|
||||
// public override extern uint32 MipLevels {get;}
|
||||
|
||||
public this(String path)
|
||||
|
||||
public this(Texture2DDesc desc)
|
||||
{
|
||||
this._path = new String(path);
|
||||
LoadTexture();
|
||||
PrepareTexturePlatform(desc, false);
|
||||
}
|
||||
|
||||
private void LoadTexture()
|
||||
public void SetData(void* data, int elementSize, TextureCubeFace cubeFace, uint32 arraySlice = 0, uint32 mipSlice = 0)
|
||||
{
|
||||
Debug.Profiler.ProfileResourceFunction!();
|
||||
|
||||
Stream data = Application.Get().ContentManager.GetStream(_path);
|
||||
defer delete data;
|
||||
|
||||
LoadTexturePlatform(data);
|
||||
PlatformSetData(data, (.)elementSize, 0, 0, Width, Height, arraySlice * 6 + (uint32)cubeFace, mipSlice, .Write);
|
||||
}
|
||||
|
||||
protected extern void LoadTexturePlatform(Stream stream);
|
||||
public void SetData<T>(T* data, TextureCubeFace cubeFace, uint32 arraySlice = 0, uint32 mipSlice = 0)
|
||||
{
|
||||
PlatformSetData(data, (.)sizeof(T), 0, 0, Width, Height, arraySlice * 6 + (uint32)cubeFace, mipSlice, .Write);
|
||||
}
|
||||
|
||||
public void SetData<T>(T* data, uint32 x, uint32 y, uint32 width, uint32 height, TextureCubeFace cubeFace, uint32 arraySlice = 0, uint32 mipSlice = 0)
|
||||
{
|
||||
PlatformSetData(data, (.)sizeof(T), x, y, width, height, arraySlice * 6 + (uint32)cubeFace, mipSlice, .Write);
|
||||
}
|
||||
|
||||
protected extern void CreateTexturePlatform(Texture2DDesc desc, bool isRenderTarget, void* data, uint32 linePitch);
|
||||
|
||||
/**
|
||||
* Prepares the texture so that a call to SetData can successfully upload the data to the gpu.
|
||||
*/
|
||||
protected extern void PrepareTexturePlatform(Texture2DDesc desc, bool isRenderTarget);
|
||||
|
||||
protected extern Result<void> PlatformSetData(void* data, uint32 elementSize, uint32 destX,
|
||||
uint32 destY, uint32 destWidth, uint32 destHeight, uint32 arraySlice, uint32 mipLevel, GlitchyEngine.Renderer.MapType mapType);
|
||||
|
||||
/**
|
||||
* Copies the texel-data of this texture to the given destination texture.
|
||||
*/
|
||||
public static extern void CopySubresourceRegion(Texture2D source, Texture2D destination,
|
||||
ResourceBox sourceBox = default, uint32 destX = 0, uint32 destY = 0,
|
||||
uint32 srcArraySlice = 0, uint32 srcMipSlice = 0, uint32 destArraySlice = 0, uint32 destMipSlice = 0);
|
||||
|
||||
/**
|
||||
* Copies the data to the given destination.
|
||||
*/
|
||||
//public extern void CopyTo(TextureCube destination);
|
||||
|
||||
public override TextureViewBinding GetViewBinding()
|
||||
{
|
||||
@@ -177,10 +182,5 @@ namespace GlitchyEngine.Renderer
|
||||
}
|
||||
|
||||
protected extern TextureViewBinding PlatformGetViewBinding();
|
||||
|
||||
protected internal override void SneakySwappyTexture(Texture otherTexture)
|
||||
{
|
||||
Runtime.NotImplemented();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user