Skip to content

Commit 7a06ca3

Browse files
[Rendering] SDLGPU WIP;
1 parent b392cd5 commit 7a06ca3

File tree

5 files changed

+8
-53
lines changed

5 files changed

+8
-53
lines changed

Engine/Staple.Core/Rendering/Access.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

Engine/Staple.Core/Rendering/Screen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static class Screen
1818
/// <summary>
1919
/// The current window mode for the game/app.
2020
/// </summary>
21-
public static WindowMode WindowMode => AppPlayer.instance == null ? WindowMode.Windowed : AppPlayer.instance.playerSettings.windowMode;
21+
public static WindowMode WindowMode => AppPlayer.instance?.playerSettings?.windowMode ?? WindowMode.Windowed;
2222

2323
/// <summary>
2424
/// The refresh rate of the screen

Engine/Staple.Core/Staple.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@
191191
<Compile Include="Rendering\Lighting\LightSystem.cs" />
192192
<Compile Include="Rendering\Lighting\LightType.cs" />
193193
<Compile Include="Rendering\MaterialLighting.cs" />
194-
<Compile Include="Rendering\Access.cs" />
195194
<Compile Include="Rendering\Mesh\MeshCombine.cs" />
196195
<Compile Include="Rendering\Mesh\MeshCombineSystem.cs" />
197196
<Compile Include="Rendering\Mesh\MeshInstanceOptions.cs" />

Engine/Staple.Editor/ImGuiProxy.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ private void Render(ImDrawDataPtr drawData)
460460
}
461461
}
462462

463-
target.Destroy();
463+
target?.Destroy();
464464

465465
target = Texture.CreatePixels($"ImGui {texture.UniqueID}", pixels,
466466
(ushort)texture.Width, (ushort)texture.Height,
@@ -474,10 +474,10 @@ private void Render(ImDrawDataPtr drawData)
474474
_ => TextureFormat.RGBA8,
475475
});
476476

477-
if(target != null)
478-
{
479-
textures[index] = (target, pixels, bytesPerPixel);
477+
textures[index] = (target, pixels, bytesPerPixel);
480478

479+
if (target != null)
480+
{
481481
texture.SetTexID(new ImTextureID(index));
482482
}
483483
else
@@ -499,7 +499,7 @@ private void Render(ImDrawDataPtr drawData)
499499

500500
if (textures.TryGetValue(index, out var item))
501501
{
502-
item.Item1.Destroy();
502+
item.Item1?.Destroy();
503503

504504
textures.Remove(index);
505505

@@ -602,11 +602,11 @@ private void Render(ImDrawDataPtr drawData)
602602
{
603603
var index = (int)drawCmd.GetTexID().Handle;
604604

605-
if (this.textures.TryGetValue(index, out var item))
605+
if (this.textures.TryGetValue(index, out var item) && item.Item1 != null)
606606
{
607607
singleTexture[0] = item.Item1;
608608
}
609-
else if (registeredTextures.TryGetValue(index, out var t))
609+
else if (registeredTextures.TryGetValue(index, out var t) && t != null)
610610
{
611611
singleTexture[0] = t;
612612
}

Tools/Baker/Baker+Shaders.cs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -666,42 +666,6 @@ threadCountYObject is long threadCountY &&
666666
}
667667
}
668668

669-
string GetNativeShaderType(ShaderParameter parameter, int index, bool uniform)
670-
{
671-
var uniformString = uniform ? "uniform " : "";
672-
var name = parameter.name;
673-
674-
if (int.TryParse(parameter.defaultValue, out var bufferIndex) == false)
675-
{
676-
bufferIndex = -1;
677-
}
678-
679-
return parameter.type switch
680-
{
681-
ShaderUniformType.Int => uniform ? $"{uniformString}vec4 {name}_uniform;\n#define {name} int({name}_uniform.x)\n" : $"float {name}",
682-
ShaderUniformType.Float => uniform ? $"{uniformString}vec4 {name}_uniform;\n#define {name} {name}_uniform.x\n" : $"float {name}",
683-
ShaderUniformType.Vector2 => uniform ? $"{uniformString}vec4 {name}_uniform;\n#define {name} {name}_uniform.xy\n" : $"vec2 {name}",
684-
ShaderUniformType.Vector3 => uniform ? $"{uniformString}vec4 {name}_uniform;\n#define {name} {name}_uniform.xyz\n" : $"vec3 {name}",
685-
ShaderUniformType.Color or ShaderUniformType.Vector4 => $"{uniformString}vec4 {name}",
686-
ShaderUniformType.Texture => $"SAMPLER2D({name}, {index})",
687-
ShaderUniformType.Matrix3x3 => $"{uniformString}mat3 {name}",
688-
ShaderUniformType.Matrix4x4 => $"{uniformString}mat4 {name}",
689-
ShaderUniformType.ReadOnlyBuffer => $"BUFFER_RO({name}, {parameter.vertexAttribute}, {bufferIndex})",
690-
ShaderUniformType.WriteOnlyBuffer => $"BUFFER_WO({name}, {parameter.vertexAttribute}, {bufferIndex})",
691-
ShaderUniformType.ReadWriteBuffer => $"BUFFER_RW({name}, {parameter.vertexAttribute}, {bufferIndex})",
692-
_ => $"{uniformString}vec4 {name}",
693-
};
694-
}
695-
696-
bool ShaderTypeHasEndTerminator(ShaderUniformType type)
697-
{
698-
return type switch
699-
{
700-
ShaderUniformType.Int or ShaderUniformType.Float or ShaderUniformType.Vector2 or ShaderUniformType.Vector3 => false,
701-
_ => true,
702-
};
703-
}
704-
705669
bool Build(string variantKey, List<string> extraDefines)
706670
{
707671
string code;

0 commit comments

Comments
 (0)