Exemplo n.º 1
0
        public void CS()
        {
            UInt3 id    = ShaderBuiltins.DispatchThreadID;
            uint  index = id.Y * Params.Width + id.X;

            Destination[index] = Source[index];
            Source[index]     += Source[index];
        }
Exemplo n.º 2
0
        public void CS()
        {
            UInt3   dtId      = ShaderBuiltins.DispatchThreadID;
            Vector4 color     = Vector4.Zero;
            uint    randState = (dtId.X * 1973 + dtId.Y * 9277 + Params.FrameCount * 26699) | 1;
            Ray     ray       = Camera.GetRay(Params.Camera, dtId.X, dtId.Y);

            color += Color(ray);
            ShaderBuiltins.Store(Output, new UInt2(dtId.X, dtId.Y), color);
        }
Exemplo n.º 3
0
 public ShaderFunction(
     string declaringType,
     string name,
     TypeReference returnType,
     ParameterDefinition[] parameters,
     ShaderFunctionType type,
     UInt3 computeGroupCounts)
 {
     DeclaringType      = declaringType;
     Name               = name;
     ReturnType         = returnType;
     Parameters         = parameters;
     Type               = type;
     ComputeGroupCounts = computeGroupCounts;
 }
        public void CS()
        {
            UInt3   dtid      = ShaderBuiltins.DispatchThreadID;
            Vector4 color     = Vector4.Zero;
            uint    randState = (dtid.X * 1973 + dtid.Y * 9277 + Params.FrameCount * 26699) | 1;

            uint rayCount = 0;

            for (uint smp = 0; smp < RayTracingApplication.NumSamples; smp++)
            {
                float u   = (dtid.X + RandUtil.RandomFloat(ref randState)) / RayTracingApplication.Width;
                float v   = (dtid.Y + RandUtil.RandomFloat(ref randState)) / RayTracingApplication.Height;
                Ray   ray = Camera.GetRay(Params.Camera, u, v, ref randState);
                color += Color(Params.SphereCount, ref randState, ray, ref rayCount);
            }
            color /= RayTracingApplication.NumSamples;
            ShaderBuiltins.Store(Output, new UInt2(dtid.X, dtid.Y), color);
            ShaderBuiltins.InterlockedAdd(RayCount, 0, rayCount);
        }
Exemplo n.º 5
0
        public void Should_SerializeUInt3()
        {
            UInt3 value = UInt3.MaxValue; // range 0 to 7

            Assert.AreEqual(1, value.GetBit(0));
            Assert.AreEqual(1, value.GetBit(1));
            Assert.AreEqual(1, value.GetBit(2));
            Assert.AreEqual(new Bit[] { 1, 1, 1 }, value.GetBits());

            value = (UInt3)2;
            Assert.AreEqual(0, value.GetBit(0));
            Assert.AreEqual(1, value.GetBit(1));
            Assert.AreEqual(new Bit[] { 0, 1, 0 }, value.GetBits());

            // test overflow
            value = (UInt3)12;
            Assert.AreEqual(4, value);
            Assert.AreEqual(0, value.GetBit(0));
            Assert.AreEqual(0, value.GetBit(1));
            Assert.AreEqual(1, value.GetBit(2));
            Assert.AreEqual(new Bit[] { 0, 0, 1 }, value.GetBits());
        }
Exemplo n.º 6
0
 internal override string GetComputeGroupCountsDeclaration(UInt3 groupCounts)
 {
     return(string.Empty);
     // This isn't actually specified in the compute shader code in Metal.
     // It's specified when an MTLComputeCommandEncoder is created.
 }
Exemplo n.º 7
0
 internal override string GetComputeGroupCountsDeclaration(UInt3 groupCounts)
 {
     return($"layout(local_size_x = {groupCounts.X}, local_size_y = {groupCounts.Y}, local_size_z = {groupCounts.Z}) in;");
 }
Exemplo n.º 8
0
 internal override string GetComputeGroupCountsDeclaration(UInt3 groupCounts)
 {
     return($"[numthreads({groupCounts.X}, {groupCounts.Y}, {groupCounts.Z})]");
 }