Exemplo n.º 1
0
        public CachedTextureResampled(CachedTexture cachedTexture)
        {
            cachedTextureOriginal = cachedTexture;
            ResampleInfo resampleInfo = new ResampleInfo(cachedTexture.width, cachedTexture.height, cachedTexture);

            resampleInfos.AddLast(resampleInfo);
        }
Exemplo n.º 2
0
        public static CachedTexture getCachedTexture(int width, int height, int pixelFormat, int[] buffer, int bufferOffset, int bufferLength)
        {
            int offset = 0;

            // When the texture is directly available from the memory,
            // we can reuse the memory array and do not need to copy the whole texture.
            if (buffer == RuntimeContext.MemoryInt)
            {
                if (pixelFormat == TPSM_PIXEL_STORAGE_MODE_32BIT_ABGR8888 || pspsharp.graphics.RE.IRenderingEngine_Fields.isTextureTypeIndexed[pixelFormat])
                {
                    // Do not reuse the memory buffer when the texture is inside the current GE,
                    // copy the texture (this is better matching the PSP texture cache behavior).
                    int textureAddress = bufferOffset << 2;
                    if (!Modules.sceDisplayModule.isGeAddress(textureAddress))
                    {
                        offset = bufferOffset;
                    }
                }
            }

            CachedTexture cachedTexture = getCachedTexture(width, height, pixelFormat, offset);

            cachedTexture.setBuffer(buffer, bufferOffset, bufferLength);

            if (buffer == RuntimeContext.MemoryInt)
            {
                int textureAddress = bufferOffset << 2;
                if (Memory.isVRAM(textureAddress))
                {
                    cachedTexture.VRAMTexture = true;
                }
            }

            return(cachedTexture);
        }
Exemplo n.º 3
0
        public static CachedTexture getCachedTexture(int width, int height, int pixelFormat, IMemoryReader imageReader)
        {
            CachedTexture cachedTexture = getCachedTexture(width, height, pixelFormat, 0);

            cachedTexture.Buffer = imageReader;

            return(cachedTexture);
        }
Exemplo n.º 4
0
        public static CachedTexture getCachedTexture(int width, int height, int pixelFormat, short[] buffer, int bufferOffset, int bufferLength)
        {
            CachedTexture cachedTexture = getCachedTexture(width, height, pixelFormat, 0);

            cachedTexture.setBuffer(buffer, bufferOffset, bufferLength);

            return(cachedTexture);
        }
Exemplo n.º 5
0
 public override void setCompressedTexImage(int level, int internalFormat, int width, int height, int compressedSize, Buffer buffer)
 {
     if (useTextureCache)
     {
         cachedTextureStatistics.start();
         // TODO Cache all the texture levels
         if (level == 0)
         {
             int                    bufferWidth            = context.texture_buffer_width[level];
             IMemoryReader          imageReader            = ImageReader.getImageReader(context.texture_base_pointer[level], width, height, bufferWidth, internalFormat, false, 0, 0, 0, 0, 0, 0, null, null);
             CachedTexture          cachedTexture          = CachedTexture.getCachedTexture(System.Math.Min(width, bufferWidth), height, internalFormat, imageReader);
             CachedTextureResampled cachedTextureResampled = new CachedTextureResampled(cachedTexture);
             cachedTextures[bindTexture_Renamed] = cachedTextureResampled;
         }
         cachedTextureStatistics.end();
     }
 }
Exemplo n.º 6
0
 public override void setTexImage(int level, int internalFormat, int width, int height, int format, int type, int textureSize, Buffer buffer)
 {
     if (useTextureCache)
     {
         cachedTextureStatistics.start();
         // TODO Cache all the texture levels
         if (level == 0)
         {
             CachedTexture cachedTexture = null;
             if (buffer is IntBuffer)
             {
                 cachedTexture = CachedTexture.getCachedTexture(textureBufferWidth, height, format, ((IntBuffer)buffer).array(), buffer.arrayOffset(), textureSize >> 2);
             }
             else if (buffer is ShortBuffer)
             {
                 cachedTexture = CachedTexture.getCachedTexture(textureBufferWidth, height, format, ((ShortBuffer)buffer).array(), buffer.arrayOffset(), textureSize >> 1);
             }
             CachedTextureResampled cachedTextureResampled = new CachedTextureResampled(cachedTexture);
             cachedTextures[bindTexture_Renamed] = cachedTextureResampled;
         }
         cachedTextureStatistics.end();
     }
 }
Exemplo n.º 7
0
 public ResampleInfo(int resampleWidth, int resampleHeight, CachedTexture cachedTextureResampled)
 {
     this.resampleWidth          = resampleWidth;
     this.resampleHeight         = resampleHeight;
     this.cachedTextureResampled = cachedTextureResampled;
 }