Example #1
0
        public DrawBufferValue GetDrawBufferTexture(DrawBufferKey key)
        {
            var value = _drawBufferTextures.GetOrDefault(key, null);

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

                openglGpuImpl.OnScaleViewport += UpdateTextures_External;
                UpdateTextures(openglGpuImpl.ScaleViewport);
            }
Example #3
0
 public DrawBufferValue GetOrCreateDrawBufferTexture(DrawBufferKey key)
 {
     if (!_drawBufferTextures.ContainsKey(key))
     {
         _drawBufferTextures[key] = new DrawBufferValue(OpenglGpuImpl, key);
     }
     return(GetDrawBufferTexture(key));
 }
Example #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();
            }
        }
Example #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);
            }
        }
Example #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();
            }
        }
Example #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);
        }
Example #8
0
            public DrawBufferValue(OpenglGpuImpl OpenglGpuImpl, DrawBufferKey DrawBufferKey)
            {
                this.OpenglGpuImpl = OpenglGpuImpl;
                this.DrawBufferKey = DrawBufferKey;

                OpenglGpuImpl.OnScaleViewport += UpdateTextures_External;
                UpdateTextures(OpenglGpuImpl.ScaleViewport);
            }
Example #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;
        }
Example #10
0
 public DrawBufferValue GetOrCreateDrawBufferTexture(DrawBufferKey Key)
 {
     if (!DrawBufferTextures.ContainsKey(Key)) DrawBufferTextures[Key] = new DrawBufferValue(OpenglGpuImpl, Key);
     return GetDrawBufferTexture(Key);
 }
Example #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);
     }
 }
Example #12
0
 public DrawBufferValue GetDrawBufferTexture(DrawBufferKey Key)
 {
     var Value = DrawBufferTextures.GetOrDefault(Key, null);
     if (Value != null) Value.WaitUnlocked();
     return Value;
 }