Engine barely starts again

This commit is contained in:
Simon Lübeß
2024-11-21 18:16:41 +01:00
parent ad73abd4ea
commit bcf75bf8cb
32 changed files with 299 additions and 161 deletions
@@ -1,5 +1,11 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 5360037389314667000 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = null,
AssetHandle = 5221334043827499251
} }
@@ -1,6 +1,6 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
Importer = "ShaderImporter", Importer = "ShaderImporter",
ImporterConfig = null, ImporterConfig = null,
Processor = null, Processor = null,
@@ -9,5 +9,5 @@
ExporterConfig = { ExporterConfig = {
_compression = .None _compression = .None
}, },
AssetHandle = 7951861132321655812 AssetHandle = 8512375832990505152
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 7082287996527160060 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 4332390465159443321
} }
@@ -1,5 +1,11 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 17297254839128368932 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = null,
AssetHandle = 9285471614459748654
} }
@@ -1,5 +1,11 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 17917061300990589192 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = null,
AssetHandle = 1287916870077203420
} }
+9 -3
View File
@@ -1,5 +1,11 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 8336560834161185660 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = null,
AssetHandle = 9019615224633186177
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 1518912886664733757 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 5246795156071151642
} }
@@ -1,5 +1,11 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 13663488523997149295 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = null,
AssetHandle = 10014069858860408945
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 9450907808112906391 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 6905134680069212587
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 4086392147967882920 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 4179932137221776017
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 3929078354809894230 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 8912920142436784175
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 5414648614681927202 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 18151489828256118978
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 17001330646928133106 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 8655864411897316846
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 2913314865396454015 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 8873320878521542705
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 9047671870217222298 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 14993433232700867484
} }
@@ -1,6 +1,6 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
Importer = "ShaderImporter", Importer = "ShaderImporter",
ImporterConfig = null, ImporterConfig = null,
Processor = null, Processor = null,
@@ -9,5 +9,5 @@
ExporterConfig = { ExporterConfig = {
_compression = .None _compression = .None
}, },
AssetHandle = 959631876667366082 AssetHandle = 9671561114069837759
} }
@@ -1,5 +1,13 @@
{ {
AssetLoader = "EffectAssetLoader", AssetLoader = null,
Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, Config = null,
AssetHandle = 10276018270467402814 Importer = "ShaderImporter",
ImporterConfig = null,
Processor = null,
ProcessorConfig = null,
Exporter = null,
ExporterConfig = {
_compression = .None
},
AssetHandle = 13990953346248142933
} }
+6 -6
View File
@@ -566,23 +566,23 @@ class TexturererViewerer
// Int Texture // Int Texture
_renderTargetEffect.Variables["Mode"].SetData(1); _renderTargetEffect.Variables["Mode"].SetData(1);
_renderTargetEffect.SetTexture("IntTexture", viewedTexture); _renderTargetEffect.SetTexture("IntTexture", viewedTexture);
_renderTargetEffect.SetTexture("UIntTexture", null); _renderTargetEffect.SetTexture("UIntTexture", (Texture)null);
_renderTargetEffect.SetTexture("Texture", null); _renderTargetEffect.SetTexture("Texture", (Texture)null);
} }
else if (format.IsUInt()) else if (format.IsUInt())
{ {
// UInt Texture // UInt Texture
_renderTargetEffect.Variables["Mode"].SetData(2); _renderTargetEffect.Variables["Mode"].SetData(2);
_renderTargetEffect.SetTexture("IntTexture", null); _renderTargetEffect.SetTexture("IntTexture", (Texture)null);
_renderTargetEffect.SetTexture("UIntTexture", viewedTexture); _renderTargetEffect.SetTexture("UIntTexture", viewedTexture);
_renderTargetEffect.SetTexture("Texture", null); _renderTargetEffect.SetTexture("Texture", (Texture)null);
} }
else else
{ {
// Float Texture // Float Texture
_renderTargetEffect.Variables["Mode"].SetData(0); _renderTargetEffect.Variables["Mode"].SetData(0);
_renderTargetEffect.SetTexture("IntTexture", null); _renderTargetEffect.SetTexture("IntTexture", (Texture)null);
_renderTargetEffect.SetTexture("UIntTexture", null); _renderTargetEffect.SetTexture("UIntTexture", (Texture)null);
_renderTargetEffect.SetTexture("Texture", viewedTexture); _renderTargetEffect.SetTexture("Texture", viewedTexture);
} }
@@ -972,6 +972,9 @@ class EditorContentManager : IContentManager
_assetConverter.QueueForProcessing(assetNode->AssetFile, isBlocking); _assetConverter.QueueForProcessing(assetNode->AssetFile, isBlocking);
var isBlocking;
isBlocking = true;
if (isBlocking) if (isBlocking)
{ {
asset = _assetCache.GetCacheEntry(handle); asset = _assetCache.GetCacheEntry(handle);
@@ -1017,6 +1020,10 @@ class EditorContentManager : IContentManager
return placeholder; return placeholder;
} }
var isBlocking;
isBlocking = true;
if (isBlocking) if (isBlocking)
return InternalLoad(asset); return InternalLoad(asset);
else else
@@ -63,13 +63,14 @@ class ShaderLoader : IProcessedAssetLoader
if (vertexShaderBindPoint != -1 && vertexShader != null) if (vertexShaderBindPoint != -1 && vertexShader != null)
{ {
vertexShader.Textures.Add(textureName, (.)vertexShaderBindPoint, entry.BoundTexture, dimension); vertexShader.Textures.Add(textureName, (.)vertexShaderBindPoint, entry.BoundTexture, dimension);
entry.VsSlot = vertexShader.Textures[textureName]; entry.VsSlot = &vertexShader.Textures[textureName];
} }
// TODO: Why is nullcheck different for vertex and pixel shader?
if (pixelShaderBindPoint != -1) if (pixelShaderBindPoint != -1)
{ {
pixelShader?.Textures.Add(textureName, (.)pixelShaderBindPoint, entry.BoundTexture, dimension); pixelShader?.Textures.Add(textureName, (.)pixelShaderBindPoint, entry.BoundTexture, dimension);
entry.PsSlot = pixelShader.Textures[textureName]; entry.PsSlot = &pixelShader.Textures[textureName];
} }
effect.Textures[textureName] = entry; effect.Textures[textureName] = entry;
@@ -19,7 +19,7 @@ namespace ImGui
ImGui.Image(view, size, uv0, uv1, tint_col, border_col); ImGui.Image(view, size, uv0, uv1, tint_col, border_col);
textureViewBinding.Release(); textureViewBinding.ReleaseRef();
} }
public static override bool ImageButton(char8* id, TextureViewBinding textureViewBinding, Vec2 imageSize, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, Vec4 bg_col = Vec4.Zero, Vec4 tint_col = Vec4.Ones) public static override bool ImageButton(char8* id, TextureViewBinding textureViewBinding, Vec2 imageSize, Vec2 uv0 = Vec2.Zero, Vec2 uv1 = Vec2.Ones, Vec4 bg_col = Vec4.Zero, Vec4 tint_col = Vec4.Ones)
@@ -29,7 +29,7 @@ namespace ImGui
bool pressed = ImGui.ImageButton(id, view, imageSize, uv0, uv1, bg_col, tint_col); bool pressed = ImGui.ImageButton(id, view, imageSize, uv0, uv1, bg_col, tint_col);
textureViewBinding.Release(); textureViewBinding.ReleaseRef();
return pressed; return pressed;
} }
@@ -41,7 +41,7 @@ namespace ImGui
bool pressed = ImGui.ImageButtonEx(id, view, imageSize, uv0, uv1, bg_col, tint_col); bool pressed = ImGui.ImageButtonEx(id, view, imageSize, uv0, uv1, bg_col, tint_col);
textureViewBinding.Release(); textureViewBinding.ReleaseRef();
return pressed; return pressed;
} }
@@ -123,7 +123,7 @@ namespace GlitchyEngine.Renderer
protected override TextureViewBinding PlatformGetViewBinding() protected override TextureViewBinding PlatformGetViewBinding()
{ {
return .(_nativeResourceView, _samplerState.nativeSamplerState); return new .(_nativeResourceView, _samplerState.nativeSamplerState);
} }
protected override void PlatformSneakySwappyTexture(RenderTarget2D otherTexture) protected override void PlatformSneakySwappyTexture(RenderTarget2D otherTexture)
@@ -448,13 +448,13 @@ namespace GlitchyEngine.Renderer
{ {
if (index == -1) if (index == -1)
{ {
return .(_nativeDepthResourceView, _depthSamplerState.nativeSamplerState); return new .(_nativeDepthResourceView, _depthSamplerState.nativeSamplerState);
} }
else else
{ {
Log.EngineLogger.AssertDebug(index < _nativeResourceViews.Count); Log.EngineLogger.AssertDebug(index < _nativeResourceViews.Count);
return .(_nativeResourceViews[index], _colorSamplerStates[index].nativeSamplerState); return new .(_nativeResourceViews[index], _colorSamplerStates[index].nativeSamplerState);
} }
} }
@@ -93,9 +93,11 @@ namespace GlitchyEngine.Renderer
{ {
SetBlendState(_nonblendingState); SetBlendState(_nonblendingState);
_clearUintFx.Variables["ClearValue"].SetData(value); var v = _clearUintFx.Get();
_clearUintFx.ApplyChanges();
_clearUintFx.Bind(); v.Variables["ClearValue"].SetData(value);
v.ApplyChanges();
v.Bind();
FullscreenQuad.Draw(); FullscreenQuad.Draw();
@@ -291,7 +291,7 @@ namespace GlitchyEngine.Renderer
protected override TextureViewBinding PlatformGetViewBinding() protected override TextureViewBinding PlatformGetViewBinding()
{ {
return .(_nativeResourceView, _samplerState?.nativeSamplerState); return new .(_nativeResourceView, _samplerState?.nativeSamplerState);
} }
} }
@@ -466,7 +466,7 @@ namespace GlitchyEngine.Renderer
protected override TextureViewBinding PlatformGetViewBinding() protected override TextureViewBinding PlatformGetViewBinding()
{ {
return .(_nativeResourceView, _samplerState?.nativeSamplerState); return new .(_nativeResourceView, _samplerState?.nativeSamplerState);
} }
} }
} }
@@ -12,24 +12,18 @@ namespace GlitchyEngine.Renderer
internal this(ID3D11ShaderResourceView* shaderResourceView, ID3D11SamplerState* samplerState) internal this(ID3D11ShaderResourceView* shaderResourceView, ID3D11SamplerState* samplerState)
{ {
_nativeShaderResourceView = shaderResourceView; _nativeShaderResourceView = shaderResourceView;
if ((uint)(void*)_nativeShaderResourceView != 0 && (uint)(void*)_nativeShaderResourceView < 200)
{
}
_nativeShaderResourceView?.AddRef(); _nativeShaderResourceView?.AddRef();
_nativeSamplerState = samplerState; _nativeSamplerState = samplerState;
_nativeSamplerState?.AddRef(); _nativeSamplerState?.AddRef();
} }
public override void AddRef() public static override TextureViewBinding CreateDefault() => new .(null, null);
{
_nativeShaderResourceView?.AddRef();
_nativeSamplerState?.AddRef();
}
public override void Release()
{
_nativeShaderResourceView?.Release();
_nativeSamplerState?.Release();
}
public static override TextureViewBinding CreateDefault() => .(null, null);
} }
} }
+2 -2
View File
@@ -153,10 +153,10 @@ namespace GlitchyEngine.Renderer
// UnorderedAccess? // UnorderedAccess?
} }
public enum BufferMiscFlags public enum BufferMiscFlags : uint8 /* Don't commit, workaround for a beef bug!*/
{ {
None = 0, None = 0,
//AllowRawView = 1, // AllowRawView = 1,
//Structured = 2, //Structured = 2,
} }
+25 -24
View File
@@ -12,26 +12,6 @@ public class Effect : Asset
internal VertexShader _vs ~ _?.ReleaseRef(); internal VertexShader _vs ~ _?.ReleaseRef();
internal PixelShader _ps ~ _?.ReleaseRef(); internal PixelShader _ps ~ _?.ReleaseRef();
typealias VariableDesc = Dictionary<String, Dictionary<String, Variant>>;
protected VariableDesc _variableDescriptions = new .() ~ {
for (var (key, value) in _)
{
delete key;
for (var (entryKey, entry) in value)
{
delete entryKey;
entry.Dispose();
}
delete value;
}
delete _;
};
BufferCollection _bufferCollection ~ _.ReleaseRef(); BufferCollection _bufferCollection ~ _.ReleaseRef();
BufferVariableCollection _variables ~ delete _; BufferVariableCollection _variables ~ delete _;
@@ -84,7 +64,7 @@ public class Effect : Asset
for(let entry in _textures) for(let entry in _textures)
{ {
entry.value.BoundTexture.Release(); entry.value.BoundTexture.ReleaseRef();
} }
} }
@@ -123,14 +103,14 @@ public class Effect : Asset
ref TextureEntry entry = ref _textures[name]; ref TextureEntry entry = ref _textures[name];
// TODO: Thats weird, we increment this reference somewhere... but WHERE?! // TODO: Thats weird, we increment this reference somewhere... but WHERE?!
entry.BoundTexture.Release(); entry.BoundTexture.ReleaseRef();
entry.BoundTexture = textureViewBinding; entry.BoundTexture = textureViewBinding;
if (entry.VsSlot != null) if (entry.VsSlot != null)
SetReferenceVar!(entry.VsSlot.BoundTexture, entry.BoundTexture); SetReference!(VertexShader.Textures[name].BoundTexture, entry.BoundTexture);
if (entry.PsSlot != null) if (entry.PsSlot != null)
SetReferenceVar!(entry.PsSlot.BoundTexture, entry.BoundTexture); SetReference!(PixelShader.Textures[name].BoundTexture, entry.BoundTexture);
} }
public void ApplyChanges() public void ApplyChanges()
@@ -158,4 +138,25 @@ public class Effect : Asset
RenderCommand.BindVertexShader(_vs); RenderCommand.BindVertexShader(_vs);
RenderCommand.BindPixelShader(_ps); RenderCommand.BindPixelShader(_ps);
} }
// Stuff I'm not sure about
typealias VariableDesc = Dictionary<String, Dictionary<String, Variant>>;
protected VariableDesc _variableDescriptions = new .() ~ {
for (var (key, value) in _)
{
delete key;
for (var (entryKey, entry) in value)
{
delete entryKey;
entry.Dispose();
}
delete value;
}
delete _;
};
} }
+8 -2
View File
@@ -364,9 +364,13 @@ namespace GlitchyEngine.Renderer
{ {
Debug.Profiler.ProfileRendererScope!("Draw Light"); Debug.Profiler.ProfileRendererScope!("Draw Light");
Effect fsEffect = TestFullscreenEffect.Get();
if (fsEffect == null)
continue;
float3 lightDir = -light.Transform.Forward; float3 lightDir = -light.Transform.Forward;
Effect fsEffect = TestFullscreenEffect.Get();
fsEffect.SetTexture("GBuffer_Albedo", _gBuffer.Target, 0); fsEffect.SetTexture("GBuffer_Albedo", _gBuffer.Target, 0);
fsEffect.SetTexture("GBuffer_Normal", _gBuffer.Target, 1); fsEffect.SetTexture("GBuffer_Normal", _gBuffer.Target, 1);
fsEffect.SetTexture("GBuffer_Tangent", _gBuffer.Target, 2); fsEffect.SetTexture("GBuffer_Tangent", _gBuffer.Target, 2);
@@ -405,18 +409,20 @@ namespace GlitchyEngine.Renderer
RenderCommand.SetRenderTargetGroup(_sceneConstants.CompositionTarget, true); RenderCommand.SetRenderTargetGroup(_sceneConstants.CompositionTarget, true);
Effect toneMappingFx = s_tonemappingEffect.Get(); Effect toneMappingFx = s_tonemappingEffect.Get();
if (toneMappingFx != null)
{
// TODO: Postprocessing effects // TODO: Postprocessing effects
toneMappingFx.SetTexture("CameraTarget", _sceneConstants.CameraTarget, 0); toneMappingFx.SetTexture("CameraTarget", _sceneConstants.CameraTarget, 0);
toneMappingFx.ApplyChanges(); toneMappingFx.ApplyChanges();
toneMappingFx.Bind(); toneMappingFx.Bind();
RenderCommand.BindRenderTargets(); RenderCommand.BindRenderTargets();
//RenderCommand.BindEffect(s_tonemappingEffect);
FullscreenQuad.Draw(); FullscreenQuad.Draw();
RenderCommand.UnbindTextures(); RenderCommand.UnbindTextures();
} }
}
// TODO: Draw lights to camera target // TODO: Draw lights to camera target
// } // }
+25 -10
View File
@@ -523,9 +523,9 @@ namespace GlitchyEngine.Renderer
Matrix viewProjection = camera.Projection * Matrix.Invert(transform); Matrix viewProjection = camera.Projection * Matrix.Invert(transform);
s_currentQuadEffect.Variables["ViewProjection"].SetData(viewProjection); s_currentQuadEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection);
s_currentCircleEffect.Variables["ViewProjection"].SetData(viewProjection); s_currentCircleEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection);
s_currentLineEffect.Variables["ViewProjection"].SetData(viewProjection); s_currentLineEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection);
s_drawOrder = drawOrder; s_drawOrder = drawOrder;
@@ -564,9 +564,9 @@ namespace GlitchyEngine.Renderer
Matrix viewProjection = camera.Projection * camera.View; Matrix viewProjection = camera.Projection * camera.View;
s_currentQuadEffect.Variables["ViewProjection"].SetData(viewProjection); s_currentQuadEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection);
s_currentCircleEffect.Variables["ViewProjection"].SetData(viewProjection); s_currentCircleEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection);
s_currentLineEffect.Variables["ViewProjection"].SetData(viewProjection); s_currentLineEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection);
s_drawOrder = drawOrder; s_drawOrder = drawOrder;
@@ -778,8 +778,13 @@ namespace GlitchyEngine.Renderer
// TODO: per object blendstate // TODO: per object blendstate
RenderCommand.SetBlendState(s_transparentBlendState); RenderCommand.SetBlendState(s_transparentBlendState);
let quadEffect = s_currentQuadEffect.Get();
if (quadEffect == null)
return;
Texture texture = s_QuadinstanceQueue[0].Texture; Texture texture = s_QuadinstanceQueue[0].Texture;
s_currentQuadEffect.SetTexture("Texture", texture); quadEffect.SetTexture("Texture", texture);
s_setQuadInstances = 0; s_setQuadInstances = 0;
@@ -793,7 +798,7 @@ namespace GlitchyEngine.Renderer
FlushQuadInstances(); FlushQuadInstances();
texture = quad.Texture; texture = quad.Texture;
s_currentQuadEffect.SetTexture("Texture", texture); quadEffect.SetTexture("Texture", texture);
} }
s_rawQuadInstances[s_setQuadInstances++] = .(quad.Transform, quad.Color, quad.uvTransform, quad.entityId); s_rawQuadInstances[s_setQuadInstances++] = .(quad.Transform, quad.Color, quad.uvTransform, quad.entityId);
@@ -819,8 +824,13 @@ namespace GlitchyEngine.Renderer
// TODO: per object blendstate // TODO: per object blendstate
RenderCommand.SetBlendState(s_transparentBlendState); RenderCommand.SetBlendState(s_transparentBlendState);
let effect = s_currentCircleEffect.Get();
if (effect == null)
return;
Texture texture = s_circleInstanceQueue[0].Texture; Texture texture = s_circleInstanceQueue[0].Texture;
s_currentCircleEffect.SetTexture("Texture", texture); effect.SetTexture("Texture", texture);
s_setCircleInstances = 0; s_setCircleInstances = 0;
@@ -834,7 +844,7 @@ namespace GlitchyEngine.Renderer
FlushCircleInstances(); FlushCircleInstances();
texture = circle.Texture; texture = circle.Texture;
s_currentCircleEffect.SetTexture("Texture", texture); effect.SetTexture("Texture", texture);
} }
s_rawCircleInstances[s_setCircleInstances++] = .(circle.Transform, circle.Color, circle.uvTransform, circle.InnerRadius, circle.entityId); s_rawCircleInstances[s_setCircleInstances++] = .(circle.Transform, circle.Color, circle.uvTransform, circle.InnerRadius, circle.entityId);
@@ -857,6 +867,11 @@ namespace GlitchyEngine.Renderer
if(s_lineInstanceQueue.IsEmpty) if(s_lineInstanceQueue.IsEmpty)
return; return;
let effect = s_currentLineEffect.Get();
if (effect == null)
return;
// TODO: per object blendstate // TODO: per object blendstate
RenderCommand.SetBlendState(s_transparentBlendState); RenderCommand.SetBlendState(s_transparentBlendState);
@@ -9,14 +9,16 @@ namespace GlitchyEngine.Renderer
List<ResourceEntry> _textures ~ DeleteTextureEntries!(_); List<ResourceEntry> _textures ~ DeleteTextureEntries!(_);
Dictionary<String, ResourceEntry*> _strToBuf ~ delete _; /*Dictionary<String, ResourceEntry*> _strToBuf ~ delete _;
Dictionary<int, ResourceEntry*> _idxToBuf ~ delete _; Dictionary<int, ResourceEntry*> _idxToBuf ~ delete _;*/
Dictionary<String, uint32> _strToBuf ~ delete _;
Dictionary<int, uint32> _idxToBuf ~ delete _;
public this() public this()
{ {
let textures = new List<ResourceEntry>(); let textures = new List<ResourceEntry>();
let strToBuf = new Dictionary<String, ResourceEntry*>(); let strToBuf = new Dictionary<String, uint32>();
let idxToBuf = new Dictionary<int, ResourceEntry*>(); let idxToBuf = new Dictionary<int, uint32>();
_textures = textures; _textures = textures;
_strToBuf = strToBuf; _strToBuf = strToBuf;
@@ -31,15 +33,15 @@ namespace GlitchyEngine.Renderer
for(let entry in entries) for(let entry in entries)
{ {
delete entry.Name; delete entry.Name;
entry.BoundTexture.Release(); entry.BoundTexture.ReleaseRef();
} }
delete entries; delete entries;
} }
// TODO: finish implementation (like BufferCollection) // TODO: finish implementation (like BufferCollection)
public ResourceEntry* this[int idx] => _idxToBuf[idx]; public ref ResourceEntry this[int idx] => ref _textures[_idxToBuf[idx]];
public ResourceEntry* this[String name] => _strToBuf[name]; public ref ResourceEntry this[String name] => ref _textures[_strToBuf[name]];
public void Add(String name, uint32 index, TextureViewBinding texture, TextureDimension dimension) public void Add(String name, uint32 index, TextureViewBinding texture, TextureDimension dimension)
{ {
@@ -53,10 +55,8 @@ namespace GlitchyEngine.Renderer
_textures.Add(copy); _textures.Add(copy);
ResourceEntry* copyRef = &_textures.Back; _strToBuf.Add(copy.Name, (uint32)(_textures.Count - 1));
_idxToBuf.Add(copy.Index, (uint32)(_textures.Count - 1));
_strToBuf.Add(copy.Name, copyRef);
_idxToBuf.Add(copy.Index, copyRef);
} }
public List<ResourceEntry>.Enumerator GetEnumerator() public List<ResourceEntry>.Enumerator GetEnumerator()
@@ -1,19 +1,15 @@
using System; using System;
using GlitchyEngine.Core;
namespace GlitchyEngine.Renderer namespace GlitchyEngine.Renderer
{ {
// TODO: I hate this. It is a reference counting struct?! // TODO: I hate this. It is a reference counting struct?!
/// Represents a reference to a texture that can be used as shader input resource. /// Represents a reference to a texture that can be used as shader input resource.
public struct TextureViewBinding : IRefCounted, IDisposable public class TextureViewBinding : RefCounter
{ {
/// True if the view binding actually has a texture. False otherwise. /// True if the view binding actually has a texture. False otherwise.
public extern bool IsEmpty { get; } public extern bool IsEmpty { get; }
public extern void AddRef();
public extern void Release();
public static extern TextureViewBinding CreateDefault(); public static extern TextureViewBinding CreateDefault();
public void Dispose() => Release();
} }
} }
+6
View File
@@ -152,6 +152,8 @@ class SceneRenderer
Effect gammaEffect = Content.GetAsset<Effect>(_gammaCorrectEffect); Effect gammaEffect = Content.GetAsset<Effect>(_gammaCorrectEffect);
if (gammaEffect != null)
{
gammaEffect.SetTexture("Texture", _compositeTarget, 0); gammaEffect.SetTexture("Texture", _compositeTarget, 0);
// TODO: iiihhh // TODO: iiihhh
gammaEffect.ApplyChanges(); gammaEffect.ApplyChanges();
@@ -159,6 +161,7 @@ class SceneRenderer
FullscreenQuad.Draw(); FullscreenQuad.Draw();
} }
}
finalTarget.ReleaseRef(); finalTarget.ReleaseRef();
} }
@@ -249,6 +252,8 @@ class SceneRenderer
Effect gammaEffect = Content.GetAsset<Effect>(_gammaCorrectEffect); Effect gammaEffect = Content.GetAsset<Effect>(_gammaCorrectEffect);
if (gammaEffect != null)
{
gammaEffect.SetTexture("Texture", _compositeTarget, 0); gammaEffect.SetTexture("Texture", _compositeTarget, 0);
// TODO: iiihhh // TODO: iiihhh
gammaEffect.ApplyChanges(); gammaEffect.ApplyChanges();
@@ -256,6 +261,7 @@ class SceneRenderer
FullscreenQuad.Draw(); FullscreenQuad.Draw();
} }
}
viewportTarget.ReleaseRef(); viewportTarget.ReleaseRef();
} }