Esempio n. 1
0
    public void BitField32_Get_Set()
    {
        var test = new BitField32();

        uint bits;

        bits = test.GetBits(0, 32);
        Assert.AreEqual(0x0, bits);

        test.SetBits(0, true);
        bits = test.GetBits(0, 32);
        Assert.AreEqual(0x1, bits);

        test.SetBits(0, true, 32);
        bits = test.GetBits(0, 32);
        Assert.AreEqual(0xffffffff, bits);
        Assert.IsTrue(test.TestAll(0, 32));

        test.SetBits(0, false, 32);
        bits = test.GetBits(0, 32);
        Assert.AreEqual(0x0, bits);

        test.SetBits(15, true, 7);
        Assert.IsTrue(test.TestAll(15, 7));
        test.SetBits(3, true, 3);
        Assert.IsTrue(test.TestAll(3, 3));
        bits = test.GetBits(0, 32);
        Assert.AreEqual(0x3f8038, bits);
        bits = test.GetBits(0, 15);
        Assert.AreEqual(0x38, bits);
        Assert.IsFalse(test.TestNone(0, 32));
        Assert.IsFalse(test.TestAll(0, 32));
        Assert.IsTrue(test.TestAny(0, 32));
    }
Esempio n. 2
0
    public void BitField32_Count_Leading_Trailing()
    {
        var test = new BitField32();

        Assert.AreEqual(0, test.CountBits());
        Assert.AreEqual(32, test.CountLeadingZeros());
        Assert.AreEqual(32, test.CountTrailingZeros());

        test.SetBits(31, true);
        Assert.AreEqual(1, test.CountBits());
        Assert.AreEqual(0, test.CountLeadingZeros());
        Assert.AreEqual(31, test.CountTrailingZeros());

        test.SetBits(0, true);
        Assert.AreEqual(2, test.CountBits());
        Assert.AreEqual(0, test.CountLeadingZeros());
        Assert.AreEqual(0, test.CountTrailingZeros());

        test.SetBits(31, false);
        Assert.AreEqual(1, test.CountBits());
        Assert.AreEqual(31, test.CountLeadingZeros());
        Assert.AreEqual(0, test.CountTrailingZeros());
    }
Esempio n. 3
0
        public void Execute(int jobId)
        {
            int2 tileId          = new int2(jobId % m_TileCount.x, jobId / m_TileCount.x);
            int2 bigTileId       = tileId / m_LastPhaseToCurTileScale;
            int2 bigTileCount    = (m_TileCount + m_LastPhaseToCurTileScale - new int2(1, 1)) / m_LastPhaseToCurTileScale;
            int  bigTileBufferID = bigTileId.x + bigTileId.y * bigTileCount.x;
            int  lightCount      = 0;

            m_ResTileLightIndicesMask[jobId].Clear();
            BitField32 lightIndicies = new BitField32();

            for (int lightIndex = 0; lightIndex < m_LightPos.Length; lightIndex++)
            {
                if (m_SrcTileLightIndicesMask[bigTileBufferID].IsSet(lightIndex))
                {
                    float3 lightPosition = m_LightPos[lightIndex];
                    var    range         = m_LightAffectingRange[lightIndex];
                    var    tileIsLit     = CullingUtls.PlaneSphereInclusion(m_ClusterInfo.ClusterXPlaneNormal[tileId.x],
                                                                            m_ClusterInfo.ClusterXPlanePoints[tileId.x], lightPosition, range) && // plane left
                                           CullingUtls.PlaneSphereInclusion(-m_ClusterInfo.ClusterXPlaneNormal[tileId.x + 1],
                                                                            m_ClusterInfo.ClusterXPlanePoints[tileId.x + 1], lightPosition, range) &&// plane right
                                           CullingUtls.PlaneSphereInclusion(m_ClusterInfo.ClusterYPlaneNormal[tileId.y],
                                                                            m_ClusterInfo.ClusterYPlanePoints[tileId.y], lightPosition, range) && // plane top
                                           CullingUtls.PlaneSphereInclusion(-m_ClusterInfo.ClusterYPlaneNormal[tileId.y + 1],
                                                                            m_ClusterInfo.ClusterYPlanePoints[tileId.y + 1], lightPosition, range);
                    uint unsignedLightIndex = (uint)lightIndex;
                    if (tileIsLit)
                    {
                        lightIndicies.SetBits(lightIndex, true);

                        m_TileLightIndicesMinMax[jobId] = new uint2(min(unsignedLightIndex, m_TileLightIndicesMinMax[jobId].x),
                                                                    max(unsignedLightIndex, m_TileLightIndicesMinMax[jobId].y));
                        lightCount += 1;
                    }
                }
            }

            m_ResTileLightIndicesMask[jobId] = lightIndicies;
            m_TileLightCount[jobId]          = lightCount;
        }