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

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

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

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