Ejemplo n.º 1
0
        public DrawBufferValue GetDrawBufferTexture(DrawBufferKey key)
        {
            var value = _drawBufferTextures.GetOrDefault(key, null);

            value?.WaitUnlocked();
            return(value);
        }
Ejemplo n.º 2
0
            public DrawBufferValue(OpenglGpuImpl openglGpuImpl, DrawBufferKey drawBufferKey)
            {
                _openglGpuImpl = openglGpuImpl;
                DrawBufferKey  = drawBufferKey;

                openglGpuImpl.OnScaleViewport += UpdateTextures_External;
                UpdateTextures(openglGpuImpl.ScaleViewport);
            }
Ejemplo n.º 3
0
 public DrawBufferValue GetOrCreateDrawBufferTexture(DrawBufferKey key)
 {
     if (!_drawBufferTextures.ContainsKey(key))
     {
         _drawBufferTextures[key] = new DrawBufferValue(OpenglGpuImpl, key);
     }
     return(GetDrawBufferTexture(key));
 }
Ejemplo n.º 4
0
        public void BindCurrentDrawBufferTexture(GpuStateStruct *gpuState)
        {
            if (_cachedBindAddress != gpuState->DrawBufferState.Address)
            {
                GL.glFlush();
                GL.glFinish();

                _cachedBindAddress = gpuState->DrawBufferState.Address;
                var key = new DrawBufferKey()
                {
                    Address = gpuState->DrawBufferState.Address,
                    //Width = (int)GpuState->DrawBufferState.Width,
                    //Height = (int)272,
                };
                CurrentDrawBuffer?.Unbind();
                CurrentDrawBuffer = GetOrCreateDrawBufferTexture(key);
                CurrentDrawBuffer.Bind();
            }
        }
Ejemplo n.º 5
0
        public void GetDrawBufferTextureAndLock(DrawBufferKey key, Action <DrawBufferValue> action)
        {
            var renderBuffer = GetDrawBufferTexture(key);

            if (renderBuffer != null)
            {
                renderBuffer.Lock();
                try
                {
                    action(renderBuffer);
                }
                finally
                {
                    renderBuffer.Unlock();
                }
            }
            else
            {
                action(null);
            }
        }
Ejemplo n.º 6
0
        public void BindCurrentDrawBufferTexture(GpuStateStruct* GpuState)
        {
            if (CachedBindAddress != GpuState->DrawBufferState.Address)
            {
                GL.glFlush();
                GL.glFinish();

                CachedBindAddress = GpuState->DrawBufferState.Address;
                var Key = new DrawBufferKey()
                {
                    Address = GpuState->DrawBufferState.Address,
                    //Width = (int)GpuState->DrawBufferState.Width,
                    //Height = (int)272,
                };
                if (CurrentDrawBuffer != null)
                {
                    CurrentDrawBuffer.Unbind();
                }
                CurrentDrawBuffer = GetOrCreateDrawBufferTexture(Key);
                CurrentDrawBuffer.Bind();
            }
        }
Ejemplo n.º 7
0
        public GLTexture TextureCacheGetAndBind(GpuStateStruct *gpuState)
        {
            if (DynarecConfig.EnableRenderTarget)
            {
                var textureMappingState = &gpuState->TextureMappingState;
                var clutState           = &textureMappingState->ClutState;
                var textureState        = &textureMappingState->TextureState;
                var key = new DrawBufferKey()
                {
                    Address = textureState->Mipmap0.Address,
                };

                if (_drawBufferTextures.ContainsKey(key))
                {
                    return(GetOrCreateDrawBufferTexture(key).RenderTarget.TextureColor.Bind());
                }
            }

            var currentTexture = OpenglGpuImpl.TextureCache.Get(gpuState);

            currentTexture.Bind();
            return(currentTexture.Texture);
        }
Ejemplo n.º 8
0
            public DrawBufferValue(OpenglGpuImpl OpenglGpuImpl, DrawBufferKey DrawBufferKey)
            {
                this.OpenglGpuImpl = OpenglGpuImpl;
                this.DrawBufferKey = DrawBufferKey;

                OpenglGpuImpl.OnScaleViewport += UpdateTextures_External;
                UpdateTextures(OpenglGpuImpl.ScaleViewport);
            }
Ejemplo n.º 9
0
        public GLTexture TextureCacheGetAndBind(GpuStateStruct* GpuState)
        {
            if (_DynarecConfig.EnableRenderTarget)
            {
                var TextureMappingState = &GpuState->TextureMappingState;
                var ClutState = &TextureMappingState->ClutState;
                var TextureState = &TextureMappingState->TextureState;
                var Key = new DrawBufferKey()
                {
                    Address = TextureState->Mipmap0.Address,
                };

                if (DrawBufferTextures.ContainsKey(Key))
                {
                    return GetOrCreateDrawBufferTexture(Key).RenderTarget.TextureColor.Bind();
                }
            }

            var CurrentTexture = OpenglGpuImpl.TextureCache.Get(GpuState);
            CurrentTexture.Bind();
            return CurrentTexture.Texture;
        }
Ejemplo n.º 10
0
 public DrawBufferValue GetOrCreateDrawBufferTexture(DrawBufferKey Key)
 {
     if (!DrawBufferTextures.ContainsKey(Key)) DrawBufferTextures[Key] = new DrawBufferValue(OpenglGpuImpl, Key);
     return GetDrawBufferTexture(Key);
 }
Ejemplo n.º 11
0
 public void GetDrawBufferTextureAndLock(DrawBufferKey Key, Action<DrawBufferValue> Action)
 {
     var RenderBuffer = GetDrawBufferTexture(Key);
     if (RenderBuffer != null)
     {
         RenderBuffer.Lock();
         try
         {
             Action(RenderBuffer);
         }
         finally
         {
             RenderBuffer.Unlock();
         }
     }
     else
     {
         Action(null);
     }
 }
Ejemplo n.º 12
0
 public DrawBufferValue GetDrawBufferTexture(DrawBufferKey Key)
 {
     var Value = DrawBufferTextures.GetOrDefault(Key, null);
     if (Value != null) Value.WaitUnlocked();
     return Value;
 }