public static unsafe ulong ValidateAndGetGpuDescriptorHandle <TPixel>(IReadWriteTexture2D <TPixel> texture, GraphicsDevice device)
            where TPixel : unmanaged
        {
            if (texture is IGraphicsResource resource)
            {
                D3D12_GPU_DESCRIPTOR_HANDLE d3D12GpuDescriptorHandle = resource.ValidateAndGetGpuDescriptorHandle(device);

                return(*(ulong *)&d3D12GpuDescriptorHandle);
            }

            return(ThrowHelper.ThrowArgumentException <ulong>("The input texture is not a valid instance"));
        }
Ejemplo n.º 2
0
    /// <inheritdoc/>
    public bool TryExecute(IReadWriteTexture2D <Float4> texture, TimeSpan time, object?parameter)
    {
        if (this.shaderFactory is Func <TimeSpan, T> shaderFactory)
        {
            texture.GraphicsDevice.ForEach(texture, this.shaderFactory(time));
        }
        else
        {
            texture.GraphicsDevice.ForEach(texture, this.statefulShaderFactory !(time, parameter));
        }

        return(true);
    }
    public bool TryExecute(IReadWriteTexture2D <Float4> texture, TimeSpan timespan, object?parameter)
    {
        if (this.texture is null ||
            this.texture.GraphicsDevice != texture.GraphicsDevice)
        {
            string filename = Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Textures", "RustyMetal.png");

            this.texture?.Dispose();

            this.texture = texture.GraphicsDevice.LoadReadOnlyTexture2D <Rgba32, Float4>(filename);
        }

        texture.GraphicsDevice.ForEach(texture, new ContouredLayers((float)timespan.TotalSeconds, this.texture));

        return(true);
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters.
 /// </summary>
 /// <typeparam name="T">The type of pixel shader to run.</typeparam>
 /// <typeparam name="TPixel">The type of pixels being processed by the shader.</typeparam>
 /// <param name="device">The <see cref="GraphicsDevice"/> to use to run the shader.</param>
 /// <param name="texture">The target texture to apply the pixel shader to.</param>
 /// <param name="shader">The input <typeparamref name="T"/> instance representing the pixel shader to run.</param>
 public static void ForEach <T, TPixel>(this GraphicsDevice device, IReadWriteTexture2D <TPixel> texture, in T shader)
Ejemplo n.º 5
0
 /// <summary>
 /// Runs the input shader on a target <see cref="GraphicsDevice"/> instance, with the specified parameters.
 /// </summary>
 /// <typeparam name="T">The type of pixel shader to run.</typeparam>
 /// <typeparam name="TPixel">The type of pixels being processed by the shader.</typeparam>
 /// <param name="device">The <see cref="GraphicsDevice"/> to use to run the shader.</param>
 /// <param name="texture">The target texture to apply the pixel shader to.</param>
 public static void ForEach <T, TPixel>(this GraphicsDevice device, IReadWriteTexture2D <TPixel> texture)
     where T : struct, IPixelShader <TPixel>
     where TPixel : unmanaged
 {
     ShaderRunner <T> .Run(device, texture, ref Unsafe.AsRef(default(T)));
 }