public DrawBufferValue GetDrawBufferTexture(DrawBufferKey key) { var value = _drawBufferTextures.GetOrDefault(key, null); value?.WaitUnlocked(); return(value); }
public DrawBufferValue(OpenglGpuImpl openglGpuImpl, DrawBufferKey drawBufferKey) { _openglGpuImpl = openglGpuImpl; DrawBufferKey = drawBufferKey; openglGpuImpl.OnScaleViewport += UpdateTextures_External; UpdateTextures(openglGpuImpl.ScaleViewport); }
public DrawBufferValue GetOrCreateDrawBufferTexture(DrawBufferKey key) { if (!_drawBufferTextures.ContainsKey(key)) { _drawBufferTextures[key] = new DrawBufferValue(OpenglGpuImpl, key); } return(GetDrawBufferTexture(key)); }
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(); } }
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); } }
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(); } }
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); }
public DrawBufferValue(OpenglGpuImpl OpenglGpuImpl, DrawBufferKey DrawBufferKey) { this.OpenglGpuImpl = OpenglGpuImpl; this.DrawBufferKey = DrawBufferKey; OpenglGpuImpl.OnScaleViewport += UpdateTextures_External; UpdateTextures(OpenglGpuImpl.ScaleViewport); }
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; }
public DrawBufferValue GetOrCreateDrawBufferTexture(DrawBufferKey Key) { if (!DrawBufferTextures.ContainsKey(Key)) DrawBufferTextures[Key] = new DrawBufferValue(OpenglGpuImpl, Key); return GetDrawBufferTexture(Key); }
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); } }
public DrawBufferValue GetDrawBufferTexture(DrawBufferKey Key) { var Value = DrawBufferTextures.GetOrDefault(Key, null); if (Value != null) Value.WaitUnlocked(); return Value; }