Пример #1
0
 public static void FindTextureSize(int width, int height, int depth, int levels, D3D9xGPU.GPUTEXTUREFORMAT format, int someType, int unknown,
                                    bool mipsPacked, int hasBorder, int expBias, uint nBlocksPitch, ref int unknown2, ref int outWidth, ref int outHeight)
 {
 }
Пример #2
0
        public static uint GetMipTailLevelOffsetCoords(int level, int width, int height, int depth, uint rowPitch, uint slicePitch, D3D9xGPU.GPUTEXTUREFORMAT format, out uint offsetX, out uint offsetY, out uint offsetZ)
        {
            uint bitsPerPixel = XboxGraphics.XGBitsPerPixelFromGpuFormat(format);

            uint blockWidth, blockHeight;

            XboxGraphics.XGGetBlockDimensions(format, out blockWidth, out blockHeight);

            int logWidth = (int)D3D.Log2Ceiling(width);
            int logHeght = (int)D3D.Log2Ceiling(height);
            int logDepth = (int)D3D.Log2Ceiling(depth);

            uint[] dimensions = { 1u << logWidth, 1u << logHeght };
            uint[] offsets    = { 0, 0, 0 };

            int lesserAxis = (logHeght < logWidth) ? 1 : 0;

            if (level >= 3)
            {
                offsets[lesserAxis ^ 1] = dimensions[lesserAxis ^ 1] >> (level - 2);
                if (offsets[lesserAxis ^ 1] < 4)
                {
                    int depthFactor = 1;
                    if (logDepth - level > 1)
                    {
                        depthFactor = logDepth - level;
                    }

                    offsets[2] = 4 * (uint)depthFactor;
                }
            }
            else
            {
                offsets[lesserAxis] = 16u >> level;
            }
            offsetX = offsets[0] / blockWidth;
            offsetY = offsets[1] / blockHeight;
            offsetZ = offsets[2];

            return((bitsPerPixel * blockWidth * offsets[0] >> 3) + rowPitch * offsets[1] + slicePitch * offsets[2]);
        }
Пример #3
0
        public static uint GetMipTailLevelOffset(int level, int width, int height, int depth, uint rowPitch, uint slicePitch, D3D9xGPU.GPUTEXTUREFORMAT format)
        {
            uint offsetX, offsetY, offsetZ;

            return(GetMipTailLevelOffsetCoords(level, width, height, depth, rowPitch, slicePitch, format, out offsetX, out offsetY, out offsetZ));
        }
Пример #4
0
        public static uint AlignTextureDimensions(ref uint width, ref uint height, ref uint depth, uint bitsPerPixel, D3D9xGPU.GPUTEXTUREFORMAT format, uint textueType, bool isTiled)
        {
            Debug.Assert(!(textueType == 0 && isTiled), "AlignTextureDimensions: 1D textures cannot be tiled");

            uint tileWidth  = 32;
            uint tileHeight = textueType != 0 ? 32u : 1u;
            uint tileDepth  = textueType != 2 ? 1u : 4u;

            uint blockWidth, blockHeight;

            XboxGraphics.XGGetBlockDimensions(format, out blockWidth, out blockHeight);

            if (!isTiled)
            {
                uint texelPitch = blockHeight * blockWidth * bitsPerPixel >> 3;
                if (texelPitch > 0)
                {
                    if (tileWidth <= 0x100 / texelPitch)
                    {
                        tileWidth = 0x100 / texelPitch;
                    }
                }
            }
            tileWidth  *= blockWidth;
            tileHeight *= blockHeight;
            width       = NextMultipleOf(width, tileWidth);
            height      = NextMultipleOf(height, tileHeight);
            depth       = NextMultipleOf(depth, tileDepth);

            uint sizeBytes = height * (bitsPerPixel * width >> 3);

            if (textueType == 2) // volume
            {
                sizeBytes = NextMultipleOf(depth * sizeBytes, 4096);
            }
            else
            {
                sizeBytes = NextMultipleOf(sizeBytes, 4096);
            }

            return(sizeBytes);
        }