diff --git a/GlitchyEditor/resources/Shaders/ACES.hlsl.ass b/GlitchyEditor/resources/Shaders/ACES.hlsl.ass index be09759..7c6562f 100644 --- a/GlitchyEditor/resources/Shaders/ACES.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/ACES.hlsl.ass @@ -1,5 +1,11 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 5360037389314667000 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = null, + AssetHandle = 5221334043827499251 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/ClearUInt.hlsl.ass b/GlitchyEditor/resources/Shaders/ClearUInt.hlsl.ass index 10001c6..af7e98f 100644 --- a/GlitchyEditor/resources/Shaders/ClearUInt.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/ClearUInt.hlsl.ass @@ -1,6 +1,6 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, + AssetLoader = null, + Config = null, Importer = "ShaderImporter", ImporterConfig = null, Processor = null, @@ -9,5 +9,5 @@ ExporterConfig = { _compression = .None }, - AssetHandle = 7951861132321655812 + AssetHandle = 8512375832990505152 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/GammaCorrect.hlsl.ass b/GlitchyEditor/resources/Shaders/GammaCorrect.hlsl.ass index 9c9d439..c257f97 100644 --- a/GlitchyEditor/resources/Shaders/GammaCorrect.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/GammaCorrect.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 7082287996527160060 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 4332390465159443321 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/GlitchyEngine.hlsl.ass b/GlitchyEditor/resources/Shaders/GlitchyEngine.hlsl.ass index 5933f91..03f296d 100644 --- a/GlitchyEditor/resources/Shaders/GlitchyEngine.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/GlitchyEngine.hlsl.ass @@ -1,5 +1,11 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 17297254839128368932 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = null, + AssetHandle = 9285471614459748654 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/LightingFunctions.hlsl.ass b/GlitchyEditor/resources/Shaders/LightingFunctions.hlsl.ass index 8d10f78..7d231ab 100644 --- a/GlitchyEditor/resources/Shaders/LightingFunctions.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/LightingFunctions.hlsl.ass @@ -1,5 +1,11 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 17917061300990589192 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = null, + AssetHandle = 1287916870077203420 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/PBR.hlsl.ass b/GlitchyEditor/resources/Shaders/PBR.hlsl.ass index 24f70b3..4dcd336 100644 --- a/GlitchyEditor/resources/Shaders/PBR.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/PBR.hlsl.ass @@ -1,5 +1,11 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 8336560834161185660 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = null, + AssetHandle = 9019615224633186177 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/RenderTargetGroupViewer.hlsl.ass b/GlitchyEditor/resources/Shaders/RenderTargetGroupViewer.hlsl.ass index 8fe571b..e4696e9 100644 --- a/GlitchyEditor/resources/Shaders/RenderTargetGroupViewer.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/RenderTargetGroupViewer.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 1518912886664733757 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 5246795156071151642 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/ShaderHelpers.hlsl.ass b/GlitchyEditor/resources/Shaders/ShaderHelpers.hlsl.ass index 77baf62..928d30a 100644 --- a/GlitchyEditor/resources/Shaders/ShaderHelpers.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/ShaderHelpers.hlsl.ass @@ -1,5 +1,11 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 13663488523997149295 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = null, + AssetHandle = 10014069858860408945 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/SimpleTonemapping.hlsl.ass b/GlitchyEditor/resources/Shaders/SimpleTonemapping.hlsl.ass index 9c1997c..fe8a7eb 100644 --- a/GlitchyEditor/resources/Shaders/SimpleTonemapping.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/SimpleTonemapping.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 9450907808112906391 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 6905134680069212587 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/circlebatch.hlsl.ass b/GlitchyEditor/resources/Shaders/circlebatch.hlsl.ass index 509a3d2..e74625a 100644 --- a/GlitchyEditor/resources/Shaders/circlebatch.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/circlebatch.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 4086392147967882920 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 4179932137221776017 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/lineShader.hlsl.ass b/GlitchyEditor/resources/Shaders/lineShader.hlsl.ass index 4bdf7d8..4efbec5 100644 --- a/GlitchyEditor/resources/Shaders/lineShader.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/lineShader.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 3929078354809894230 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 8912920142436784175 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/linebatch.hlsl.ass b/GlitchyEditor/resources/Shaders/linebatch.hlsl.ass index 95fd11e..2ba60d8 100644 --- a/GlitchyEditor/resources/Shaders/linebatch.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/linebatch.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 5414648614681927202 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 18151489828256118978 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/msdfShader.hlsl.ass b/GlitchyEditor/resources/Shaders/msdfShader.hlsl.ass index 44a0563..e7d92b6 100644 --- a/GlitchyEditor/resources/Shaders/msdfShader.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/msdfShader.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 17001330646928133106 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 8655864411897316846 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/myEffect.hlsl.ass b/GlitchyEditor/resources/Shaders/myEffect.hlsl.ass index 2b6f675..58a7d93 100644 --- a/GlitchyEditor/resources/Shaders/myEffect.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/myEffect.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 2913314865396454015 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 8873320878521542705 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/simpleLight.hlsl.ass b/GlitchyEditor/resources/Shaders/simpleLight.hlsl.ass index 2451690..78e09ff 100644 --- a/GlitchyEditor/resources/Shaders/simpleLight.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/simpleLight.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 9047671870217222298 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 14993433232700867484 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/spritebatch.hlsl.ass b/GlitchyEditor/resources/Shaders/spritebatch.hlsl.ass index f0725b7..7a1cca2 100644 --- a/GlitchyEditor/resources/Shaders/spritebatch.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/spritebatch.hlsl.ass @@ -1,6 +1,6 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, + AssetLoader = null, + Config = null, Importer = "ShaderImporter", ImporterConfig = null, Processor = null, @@ -9,5 +9,5 @@ ExporterConfig = { _compression = .None }, - AssetHandle = 959631876667366082 + AssetHandle = 9671561114069837759 } \ No newline at end of file diff --git a/GlitchyEditor/resources/Shaders/textureViewerShader.hlsl.ass b/GlitchyEditor/resources/Shaders/textureViewerShader.hlsl.ass index f704c28..331ee16 100644 --- a/GlitchyEditor/resources/Shaders/textureViewerShader.hlsl.ass +++ b/GlitchyEditor/resources/Shaders/textureViewerShader.hlsl.ass @@ -1,5 +1,13 @@ { - AssetLoader = "EffectAssetLoader", - Config = (GlitchyEditor.Assets.EffectAssetLoaderConfig){}/* No reflection data for GlitchyEditor.Assets.EffectAssetLoaderConfig. Add [BonTarget] or force it */, - AssetHandle = 10276018270467402814 + AssetLoader = null, + Config = null, + Importer = "ShaderImporter", + ImporterConfig = null, + Processor = null, + ProcessorConfig = null, + Exporter = null, + ExporterConfig = { + _compression = .None + }, + AssetHandle = 13990953346248142933 } \ No newline at end of file diff --git a/GlitchyEditor/src/EditWindows/AssetViewer.bf b/GlitchyEditor/src/EditWindows/AssetViewer.bf index a1e7c98..07d3c19 100644 --- a/GlitchyEditor/src/EditWindows/AssetViewer.bf +++ b/GlitchyEditor/src/EditWindows/AssetViewer.bf @@ -566,23 +566,23 @@ class TexturererViewerer // Int Texture _renderTargetEffect.Variables["Mode"].SetData(1); _renderTargetEffect.SetTexture("IntTexture", viewedTexture); - _renderTargetEffect.SetTexture("UIntTexture", null); - _renderTargetEffect.SetTexture("Texture", null); + _renderTargetEffect.SetTexture("UIntTexture", (Texture)null); + _renderTargetEffect.SetTexture("Texture", (Texture)null); } else if (format.IsUInt()) { // UInt Texture _renderTargetEffect.Variables["Mode"].SetData(2); - _renderTargetEffect.SetTexture("IntTexture", null); + _renderTargetEffect.SetTexture("IntTexture", (Texture)null); _renderTargetEffect.SetTexture("UIntTexture", viewedTexture); - _renderTargetEffect.SetTexture("Texture", null); + _renderTargetEffect.SetTexture("Texture", (Texture)null); } else { // Float Texture _renderTargetEffect.Variables["Mode"].SetData(0); - _renderTargetEffect.SetTexture("IntTexture", null); - _renderTargetEffect.SetTexture("UIntTexture", null); + _renderTargetEffect.SetTexture("IntTexture", (Texture)null); + _renderTargetEffect.SetTexture("UIntTexture", (Texture)null); _renderTargetEffect.SetTexture("Texture", viewedTexture); } diff --git a/GlitchyEditor/src/EditorContentManager.bf b/GlitchyEditor/src/EditorContentManager.bf index bf7504d..89356b6 100644 --- a/GlitchyEditor/src/EditorContentManager.bf +++ b/GlitchyEditor/src/EditorContentManager.bf @@ -971,7 +971,10 @@ class EditorContentManager : IContentManager TreeNode assetNode = TrySilent!(AssetHierarchy.GetNodeFromAssetHandle(handle)); _assetConverter.QueueForProcessing(assetNode->AssetFile, isBlocking); - + + var isBlocking; + isBlocking = true; + if (isBlocking) { asset = _assetCache.GetCacheEntry(handle); @@ -1017,6 +1020,10 @@ class EditorContentManager : IContentManager return placeholder; } + var isBlocking; + + isBlocking = true; + if (isBlocking) return InternalLoad(asset); else diff --git a/GlitchyEngine/src/Content/Loaders/ShaderLoader.bf b/GlitchyEngine/src/Content/Loaders/ShaderLoader.bf index fe986c2..6c9f78d 100644 --- a/GlitchyEngine/src/Content/Loaders/ShaderLoader.bf +++ b/GlitchyEngine/src/Content/Loaders/ShaderLoader.bf @@ -63,13 +63,14 @@ class ShaderLoader : IProcessedAssetLoader if (vertexShaderBindPoint != -1 && vertexShader != null) { 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) { pixelShader?.Textures.Add(textureName, (.)pixelShaderBindPoint, entry.BoundTexture, dimension); - entry.PsSlot = pixelShader.Textures[textureName]; + entry.PsSlot = &pixelShader.Textures[textureName]; } effect.Textures[textureName] = entry; diff --git a/GlitchyEngine/src/Platform/DX11/ImGui/Dx11ImGui.bf b/GlitchyEngine/src/Platform/DX11/ImGui/Dx11ImGui.bf index bf1ec80..b4a8c2a 100644 --- a/GlitchyEngine/src/Platform/DX11/ImGui/Dx11ImGui.bf +++ b/GlitchyEngine/src/Platform/DX11/ImGui/Dx11ImGui.bf @@ -19,7 +19,7 @@ namespace ImGui 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) @@ -29,7 +29,7 @@ namespace ImGui bool pressed = ImGui.ImageButton(id, view, imageSize, uv0, uv1, bg_col, tint_col); - textureViewBinding.Release(); + textureViewBinding.ReleaseRef(); return pressed; } @@ -41,7 +41,7 @@ namespace ImGui bool pressed = ImGui.ImageButtonEx(id, view, imageSize, uv0, uv1, bg_col, tint_col); - textureViewBinding.Release(); + textureViewBinding.ReleaseRef(); return pressed; } diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RenderTarget.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RenderTarget.bf index ef2be58..a479edb 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RenderTarget.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RenderTarget.bf @@ -123,7 +123,7 @@ namespace GlitchyEngine.Renderer protected override TextureViewBinding PlatformGetViewBinding() { - return .(_nativeResourceView, _samplerState.nativeSamplerState); + return new .(_nativeResourceView, _samplerState.nativeSamplerState); } protected override void PlatformSneakySwappyTexture(RenderTarget2D otherTexture) @@ -448,13 +448,13 @@ namespace GlitchyEngine.Renderer { if (index == -1) { - return .(_nativeDepthResourceView, _depthSamplerState.nativeSamplerState); + return new .(_nativeDepthResourceView, _depthSamplerState.nativeSamplerState); } else { Log.EngineLogger.AssertDebug(index < _nativeResourceViews.Count); - return .(_nativeResourceViews[index], _colorSamplerStates[index].nativeSamplerState); + return new .(_nativeResourceViews[index], _colorSamplerStates[index].nativeSamplerState); } } diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RendererAPI.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RendererAPI.bf index 98b1893..1585783 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RendererAPI.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11RendererAPI.bf @@ -92,10 +92,12 @@ namespace GlitchyEngine.Renderer using (BlendState lastBlendState = _currentBlendState..AddRef()) { SetBlendState(_nonblendingState); - - _clearUintFx.Variables["ClearValue"].SetData(value); - _clearUintFx.ApplyChanges(); - _clearUintFx.Bind(); + + var v = _clearUintFx.Get(); + + v.Variables["ClearValue"].SetData(value); + v.ApplyChanges(); + v.Bind(); FullscreenQuad.Draw(); diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf index 75f0761..9c3ee97 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11Texture.bf @@ -291,7 +291,7 @@ namespace GlitchyEngine.Renderer protected override TextureViewBinding PlatformGetViewBinding() { - return .(_nativeResourceView, _samplerState?.nativeSamplerState); + return new .(_nativeResourceView, _samplerState?.nativeSamplerState); } } @@ -466,7 +466,7 @@ namespace GlitchyEngine.Renderer protected override TextureViewBinding PlatformGetViewBinding() { - return .(_nativeResourceView, _samplerState?.nativeSamplerState); + return new .(_nativeResourceView, _samplerState?.nativeSamplerState); } } } diff --git a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11TextureViewBinding.bf b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11TextureViewBinding.bf index 99b738e..87c880c 100644 --- a/GlitchyEngine/src/Platform/DX11/Renderer/Dx11TextureViewBinding.bf +++ b/GlitchyEngine/src/Platform/DX11/Renderer/Dx11TextureViewBinding.bf @@ -12,24 +12,18 @@ namespace GlitchyEngine.Renderer internal this(ID3D11ShaderResourceView* shaderResourceView, ID3D11SamplerState* samplerState) { _nativeShaderResourceView = shaderResourceView; + + if ((uint)(void*)_nativeShaderResourceView != 0 && (uint)(void*)_nativeShaderResourceView < 200) + { + + } + _nativeShaderResourceView?.AddRef(); _nativeSamplerState = samplerState; _nativeSamplerState?.AddRef(); } - public override void AddRef() - { - _nativeShaderResourceView?.AddRef(); - _nativeSamplerState?.AddRef(); - } - - public override void Release() - { - _nativeShaderResourceView?.Release(); - _nativeSamplerState?.Release(); - } - - public static override TextureViewBinding CreateDefault() => .(null, null); + public static override TextureViewBinding CreateDefault() => new .(null, null); } } diff --git a/GlitchyEngine/src/Renderer/Buffer.bf b/GlitchyEngine/src/Renderer/Buffer.bf index 0b8f65d..d39624f 100644 --- a/GlitchyEngine/src/Renderer/Buffer.bf +++ b/GlitchyEngine/src/Renderer/Buffer.bf @@ -153,10 +153,10 @@ namespace GlitchyEngine.Renderer // UnorderedAccess? } - public enum BufferMiscFlags + public enum BufferMiscFlags : uint8 /* Don't commit, workaround for a beef bug!*/ { None = 0, - //AllowRawView = 1, + // AllowRawView = 1, //Structured = 2, } diff --git a/GlitchyEngine/src/Renderer/Effect.bf b/GlitchyEngine/src/Renderer/Effect.bf index 8c7b0df..7893afe 100644 --- a/GlitchyEngine/src/Renderer/Effect.bf +++ b/GlitchyEngine/src/Renderer/Effect.bf @@ -12,26 +12,6 @@ public class Effect : Asset internal VertexShader _vs ~ _?.ReleaseRef(); internal PixelShader _ps ~ _?.ReleaseRef(); - typealias VariableDesc = Dictionary>; - - 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(); BufferVariableCollection _variables ~ delete _; @@ -84,7 +64,7 @@ public class Effect : Asset 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]; // TODO: Thats weird, we increment this reference somewhere... but WHERE?! - entry.BoundTexture.Release(); + entry.BoundTexture.ReleaseRef(); entry.BoundTexture = textureViewBinding; if (entry.VsSlot != null) - SetReferenceVar!(entry.VsSlot.BoundTexture, entry.BoundTexture); + SetReference!(VertexShader.Textures[name].BoundTexture, entry.BoundTexture); if (entry.PsSlot != null) - SetReferenceVar!(entry.PsSlot.BoundTexture, entry.BoundTexture); + SetReference!(PixelShader.Textures[name].BoundTexture, entry.BoundTexture); } public void ApplyChanges() @@ -158,4 +138,25 @@ public class Effect : Asset RenderCommand.BindVertexShader(_vs); RenderCommand.BindPixelShader(_ps); } + + // Stuff I'm not sure about + + typealias VariableDesc = Dictionary>; + + protected VariableDesc _variableDescriptions = new .() ~ { + for (var (key, value) in _) + { + delete key; + + for (var (entryKey, entry) in value) + { + delete entryKey; + entry.Dispose(); + } + + delete value; + } + + delete _; + }; } diff --git a/GlitchyEngine/src/Renderer/Renderer.bf b/GlitchyEngine/src/Renderer/Renderer.bf index 56d56a7..6d0a6f7 100644 --- a/GlitchyEngine/src/Renderer/Renderer.bf +++ b/GlitchyEngine/src/Renderer/Renderer.bf @@ -364,9 +364,13 @@ namespace GlitchyEngine.Renderer { Debug.Profiler.ProfileRendererScope!("Draw Light"); + Effect fsEffect = TestFullscreenEffect.Get(); + + if (fsEffect == null) + continue; + float3 lightDir = -light.Transform.Forward; - Effect fsEffect = TestFullscreenEffect.Get(); fsEffect.SetTexture("GBuffer_Albedo", _gBuffer.Target, 0); fsEffect.SetTexture("GBuffer_Normal", _gBuffer.Target, 1); fsEffect.SetTexture("GBuffer_Tangent", _gBuffer.Target, 2); @@ -405,17 +409,19 @@ namespace GlitchyEngine.Renderer RenderCommand.SetRenderTargetGroup(_sceneConstants.CompositionTarget, true); Effect toneMappingFx = s_tonemappingEffect.Get(); - // TODO: Postprocessing effects - toneMappingFx.SetTexture("CameraTarget", _sceneConstants.CameraTarget, 0); - toneMappingFx.ApplyChanges(); - toneMappingFx.Bind(); - - RenderCommand.BindRenderTargets(); - //RenderCommand.BindEffect(s_tonemappingEffect); - - FullscreenQuad.Draw(); - - RenderCommand.UnbindTextures(); + if (toneMappingFx != null) + { + // TODO: Postprocessing effects + toneMappingFx.SetTexture("CameraTarget", _sceneConstants.CameraTarget, 0); + toneMappingFx.ApplyChanges(); + toneMappingFx.Bind(); + + RenderCommand.BindRenderTargets(); + + FullscreenQuad.Draw(); + + RenderCommand.UnbindTextures(); + } } // TODO: Draw lights to camera target diff --git a/GlitchyEngine/src/Renderer/Renderer2D.bf b/GlitchyEngine/src/Renderer/Renderer2D.bf index cbbaf26..7acf382 100644 --- a/GlitchyEngine/src/Renderer/Renderer2D.bf +++ b/GlitchyEngine/src/Renderer/Renderer2D.bf @@ -522,10 +522,10 @@ namespace GlitchyEngine.Renderer s_currentLineEffect = s_lineBatchEffect; Matrix viewProjection = camera.Projection * Matrix.Invert(transform); - - s_currentQuadEffect.Variables["ViewProjection"].SetData(viewProjection); - s_currentCircleEffect.Variables["ViewProjection"].SetData(viewProjection); - s_currentLineEffect.Variables["ViewProjection"].SetData(viewProjection); + + s_currentQuadEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection); + s_currentCircleEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection); + s_currentLineEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection); s_drawOrder = drawOrder; @@ -564,9 +564,9 @@ namespace GlitchyEngine.Renderer Matrix viewProjection = camera.Projection * camera.View; - s_currentQuadEffect.Variables["ViewProjection"].SetData(viewProjection); - s_currentCircleEffect.Variables["ViewProjection"].SetData(viewProjection); - s_currentLineEffect.Variables["ViewProjection"].SetData(viewProjection); + s_currentQuadEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection); + s_currentCircleEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection); + s_currentLineEffect.Get()?.Variables["ViewProjection"].SetData(viewProjection); s_drawOrder = drawOrder; @@ -778,8 +778,13 @@ namespace GlitchyEngine.Renderer // TODO: per object blendstate RenderCommand.SetBlendState(s_transparentBlendState); + let quadEffect = s_currentQuadEffect.Get(); + + if (quadEffect == null) + return; + Texture texture = s_QuadinstanceQueue[0].Texture; - s_currentQuadEffect.SetTexture("Texture", texture); + quadEffect.SetTexture("Texture", texture); s_setQuadInstances = 0; @@ -793,7 +798,7 @@ namespace GlitchyEngine.Renderer FlushQuadInstances(); texture = quad.Texture; - s_currentQuadEffect.SetTexture("Texture", texture); + quadEffect.SetTexture("Texture", texture); } s_rawQuadInstances[s_setQuadInstances++] = .(quad.Transform, quad.Color, quad.uvTransform, quad.entityId); @@ -818,9 +823,14 @@ namespace GlitchyEngine.Renderer // TODO: per object blendstate RenderCommand.SetBlendState(s_transparentBlendState); + + let effect = s_currentCircleEffect.Get(); + + if (effect == null) + return; Texture texture = s_circleInstanceQueue[0].Texture; - s_currentCircleEffect.SetTexture("Texture", texture); + effect.SetTexture("Texture", texture); s_setCircleInstances = 0; @@ -834,7 +844,7 @@ namespace GlitchyEngine.Renderer FlushCircleInstances(); 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); @@ -857,6 +867,11 @@ namespace GlitchyEngine.Renderer if(s_lineInstanceQueue.IsEmpty) return; + let effect = s_currentLineEffect.Get(); + + if (effect == null) + return; + // TODO: per object blendstate RenderCommand.SetBlendState(s_transparentBlendState); diff --git a/GlitchyEngine/src/Renderer/ShaderTextureCollection.bf b/GlitchyEngine/src/Renderer/ShaderTextureCollection.bf index 2587af8..78fce57 100644 --- a/GlitchyEngine/src/Renderer/ShaderTextureCollection.bf +++ b/GlitchyEngine/src/Renderer/ShaderTextureCollection.bf @@ -9,14 +9,16 @@ namespace GlitchyEngine.Renderer List _textures ~ DeleteTextureEntries!(_); - Dictionary _strToBuf ~ delete _; - Dictionary _idxToBuf ~ delete _; + /*Dictionary _strToBuf ~ delete _; + Dictionary _idxToBuf ~ delete _;*/ + Dictionary _strToBuf ~ delete _; + Dictionary _idxToBuf ~ delete _; public this() { let textures = new List(); - let strToBuf = new Dictionary(); - let idxToBuf = new Dictionary(); + let strToBuf = new Dictionary(); + let idxToBuf = new Dictionary(); _textures = textures; _strToBuf = strToBuf; @@ -31,15 +33,15 @@ namespace GlitchyEngine.Renderer for(let entry in entries) { delete entry.Name; - entry.BoundTexture.Release(); + entry.BoundTexture.ReleaseRef(); } delete entries; } // TODO: finish implementation (like BufferCollection) - public ResourceEntry* this[int idx] => _idxToBuf[idx]; - public ResourceEntry* this[String name] => _strToBuf[name]; + public ref ResourceEntry this[int idx] => ref _textures[_idxToBuf[idx]]; + public ref ResourceEntry this[String name] => ref _textures[_strToBuf[name]]; public void Add(String name, uint32 index, TextureViewBinding texture, TextureDimension dimension) { @@ -53,10 +55,8 @@ namespace GlitchyEngine.Renderer _textures.Add(copy); - ResourceEntry* copyRef = &_textures.Back; - - _strToBuf.Add(copy.Name, copyRef); - _idxToBuf.Add(copy.Index, copyRef); + _strToBuf.Add(copy.Name, (uint32)(_textures.Count - 1)); + _idxToBuf.Add(copy.Index, (uint32)(_textures.Count - 1)); } public List.Enumerator GetEnumerator() diff --git a/GlitchyEngine/src/Renderer/TextureViewBinding.bf b/GlitchyEngine/src/Renderer/TextureViewBinding.bf index ff67b25..721886e 100644 --- a/GlitchyEngine/src/Renderer/TextureViewBinding.bf +++ b/GlitchyEngine/src/Renderer/TextureViewBinding.bf @@ -1,19 +1,15 @@ using System; +using GlitchyEngine.Core; namespace GlitchyEngine.Renderer { // TODO: I hate this. It is a reference counting struct?! /// 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. public extern bool IsEmpty { get; } - public extern void AddRef(); - public extern void Release(); - public static extern TextureViewBinding CreateDefault(); - - public void Dispose() => Release(); } } diff --git a/GlitchyEngine/src/World/SceneRenderer.bf b/GlitchyEngine/src/World/SceneRenderer.bf index 29bc213..6ae08b1 100644 --- a/GlitchyEngine/src/World/SceneRenderer.bf +++ b/GlitchyEngine/src/World/SceneRenderer.bf @@ -152,12 +152,15 @@ class SceneRenderer Effect gammaEffect = Content.GetAsset(_gammaCorrectEffect); - gammaEffect.SetTexture("Texture", _compositeTarget, 0); - // TODO: iiihhh - gammaEffect.ApplyChanges(); - gammaEffect.Bind(); + if (gammaEffect != null) + { + gammaEffect.SetTexture("Texture", _compositeTarget, 0); + // TODO: iiihhh + gammaEffect.ApplyChanges(); + gammaEffect.Bind(); - FullscreenQuad.Draw(); + FullscreenQuad.Draw(); + } } finalTarget.ReleaseRef(); @@ -249,12 +252,15 @@ class SceneRenderer Effect gammaEffect = Content.GetAsset(_gammaCorrectEffect); - gammaEffect.SetTexture("Texture", _compositeTarget, 0); - // TODO: iiihhh - gammaEffect.ApplyChanges(); - gammaEffect.Bind(); + if (gammaEffect != null) + { + gammaEffect.SetTexture("Texture", _compositeTarget, 0); + // TODO: iiihhh + gammaEffect.ApplyChanges(); + gammaEffect.Bind(); - FullscreenQuad.Draw(); + FullscreenQuad.Draw(); + } } viewportTarget.ReleaseRef();