TextureSamplerBinding now stores IntPtrs

main
cosmonaut 2022-05-23 19:12:17 -07:00
parent 4756fe2b14
commit 9862bfd0a0
2 changed files with 19 additions and 11 deletions

View File

@ -1,14 +1,22 @@
namespace MoonWorks.Graphics using System;
namespace MoonWorks.Graphics
{ {
public struct TextureSamplerBinding public struct TextureSamplerBinding
{ {
public Texture Texture; public IntPtr TextureHandle;
public Sampler Sampler; public IntPtr SamplerHandle;
public TextureSamplerBinding(Texture texture, Sampler sampler) public TextureSamplerBinding(Texture texture, Sampler sampler)
{ {
Texture = texture; TextureHandle = texture.Handle;
Sampler = sampler; SamplerHandle = sampler.Handle;
}
public TextureSamplerBinding(IntPtr textureHandle, IntPtr samplerHandle)
{
TextureHandle = textureHandle;
SamplerHandle = samplerHandle;
} }
} }
} }

View File

@ -425,8 +425,8 @@ namespace MoonWorks.Graphics
for (var i = 0; i < length; i += 1) for (var i = 0; i < length; i += 1)
{ {
texturePtrs[i] = textureSamplerBindings[i].Texture.Handle; texturePtrs[i] = textureSamplerBindings[i].TextureHandle;
samplerPtrs[i] = textureSamplerBindings[i].Sampler.Handle; samplerPtrs[i] = textureSamplerBindings[i].SamplerHandle;
} }
Refresh.Refresh_BindVertexSamplers( Refresh.Refresh_BindVertexSamplers(
@ -464,18 +464,18 @@ namespace MoonWorks.Graphics
for (var i = 0; i < length; i += 1) for (var i = 0; i < length; i += 1)
{ {
#if DEBUG #if DEBUG
if (textureSamplerBindings[i].Texture == null) if (textureSamplerBindings[i].TextureHandle == IntPtr.Zero)
{ {
throw new NullReferenceException("Texture binding must not be null!"); throw new NullReferenceException("Texture binding must not be null!");
} }
if (textureSamplerBindings[i].Texture == null) if (textureSamplerBindings[i].TextureHandle == IntPtr.Zero)
{ {
throw new NullReferenceException("Sampler binding must not be null!"); throw new NullReferenceException("Sampler binding must not be null!");
} }
#endif #endif
texturePtrs[i] = textureSamplerBindings[i].Texture.Handle; texturePtrs[i] = textureSamplerBindings[i].TextureHandle;
samplerPtrs[i] = textureSamplerBindings[i].Sampler.Handle; samplerPtrs[i] = textureSamplerBindings[i].SamplerHandle;
} }
Refresh.Refresh_BindFragmentSamplers( Refresh.Refresh_BindFragmentSamplers(