phase(N.5) Task 2: parallel Texture2DArray upload path in TextureCache
Adds UploadRgba8AsLayer1Array — uploads pixel data as a 1-layer Texture2DArray. Existing UploadRgba8 (Texture2D) untouched, so legacy callers (StaticMeshRenderer, InstancedMeshRenderer, ParticleRenderer, WbDrawDispatcher's pre-rewrite path) keep working unchanged. Required for Task 3's Bindless* methods which need the Texture2DArray target so the WB modern shader can sample via sampler2DArray. Same surface may be uploaded both ways during the N.5/N.6 transition; doubling is bounded and acceptable. After N.6 retires legacy renderers entirely, the legacy UploadRgba8 becomes unused and is deleted. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
aba2cfc3b6
commit
f48a6cf65c
1 changed files with 32 additions and 0 deletions
|
|
@ -279,6 +279,38 @@ public sealed unsafe class TextureCache : Wb.ITextureCachePerInstance, IDisposab
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Variant of <see cref="UploadRgba8"/> that uploads pixel data as a 1-layer
|
||||||
|
/// Texture2DArray. Required by the WB modern rendering path which samples via
|
||||||
|
/// sampler2DArray in its bindless shader. Pixel data is identical.
|
||||||
|
/// </summary>
|
||||||
|
private uint UploadRgba8AsLayer1Array(DecodedTexture decoded)
|
||||||
|
{
|
||||||
|
uint tex = _gl.GenTexture();
|
||||||
|
_gl.BindTexture(TextureTarget.Texture2DArray, tex);
|
||||||
|
|
||||||
|
fixed (byte* p = decoded.Rgba8)
|
||||||
|
_gl.TexImage3D(
|
||||||
|
TextureTarget.Texture2DArray,
|
||||||
|
0,
|
||||||
|
InternalFormat.Rgba8,
|
||||||
|
(uint)decoded.Width,
|
||||||
|
(uint)decoded.Height,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
PixelFormat.Rgba,
|
||||||
|
PixelType.UnsignedByte,
|
||||||
|
p);
|
||||||
|
|
||||||
|
_gl.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
|
||||||
|
_gl.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||||
|
_gl.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
|
||||||
|
_gl.TexParameter(TextureTarget.Texture2DArray, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
|
||||||
|
|
||||||
|
_gl.BindTexture(TextureTarget.Texture2DArray, 0);
|
||||||
|
return tex;
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
foreach (var h in _handlesBySurfaceId.Values)
|
foreach (var h in _handlesBySurfaceId.Values)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue