mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Adds commentary, shrinks some intermediate texture sizes.
This commit is contained in:
parent
1e1f007bb7
commit
bb547610f2
@ -30,8 +30,8 @@ struct Uniforms {
|
|||||||
float cyclesMultiplier;
|
float cyclesMultiplier;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr size_t NumBufferedScans = 2048;
|
constexpr size_t NumBufferedLines = 500;
|
||||||
constexpr size_t NumBufferedLines = 2048;
|
constexpr size_t NumBufferedScans = NumBufferedLines * 4;
|
||||||
|
|
||||||
/// The shared resource options this app would most favour; applied as widely as possible.
|
/// The shared resource options this app would most favour; applied as widely as possible.
|
||||||
constexpr MTLResourceOptions SharedResourceOptionsStandard = MTLResourceCPUCacheModeWriteCombined | MTLResourceStorageModeShared;
|
constexpr MTLResourceOptions SharedResourceOptionsStandard = MTLResourceCPUCacheModeWriteCombined | MTLResourceStorageModeShared;
|
||||||
@ -58,41 +58,58 @@ constexpr MTLResourceOptions SharedResourceOptionsTexture = MTLResourceCPUCacheM
|
|||||||
using BufferingScanTarget = Outputs::Display::BufferingScanTarget;
|
using BufferingScanTarget = Outputs::Display::BufferingScanTarget;
|
||||||
|
|
||||||
@implementation CSScanTarget {
|
@implementation CSScanTarget {
|
||||||
|
// The command queue for the device in use.
|
||||||
id<MTLCommandQueue> _commandQueue;
|
id<MTLCommandQueue> _commandQueue;
|
||||||
|
|
||||||
id<MTLFunction> _vertexShader;
|
// Pipelines.
|
||||||
id<MTLFunction> _fragmentShader;
|
id<MTLRenderPipelineState> _composePipeline; // For rendering to the composition texture.
|
||||||
|
id<MTLRenderPipelineState> _outputPipeline; // For drawing to the frame buffer.
|
||||||
id<MTLRenderPipelineState> _composePipeline;
|
id<MTLRenderPipelineState> _copyPipeline; // For copying the frame buffer to the visible surface.
|
||||||
id<MTLRenderPipelineState> _outputPipeline;
|
id<MTLRenderPipelineState> _clearPipeline; // For applying additional inter-frame clearing (cf. the stencil).
|
||||||
id<MTLRenderPipelineState> _copyPipeline;
|
|
||||||
id<MTLRenderPipelineState> _clearPipeline;
|
|
||||||
|
|
||||||
// Buffers.
|
// Buffers.
|
||||||
id<MTLBuffer> _uniformsBuffer;
|
id<MTLBuffer> _uniformsBuffer; // A static buffer, containing a copy of the Uniforms struct.
|
||||||
|
id<MTLBuffer> _scansBuffer; // A dynamic buffer, into which the CPU writes Scans for later display.
|
||||||
|
id<MTLBuffer> _linesBuffer; // A dynamic buffer, into which the CPU writes Lines for later display.
|
||||||
|
|
||||||
id<MTLBuffer> _scansBuffer;
|
// Textures: the write area.
|
||||||
id<MTLBuffer> _linesBuffer;
|
//
|
||||||
id<MTLBuffer> _writeAreaBuffer;
|
// The write area receives fragments of output from the emulated machine.
|
||||||
|
// So it is written by the CPU and read by the GPU.
|
||||||
// Textures.
|
|
||||||
id<MTLTexture> _writeAreaTexture;
|
id<MTLTexture> _writeAreaTexture;
|
||||||
size_t _bytesPerInputPixel;
|
id<MTLBuffer> _writeAreaBuffer; // The storage underlying the write-area texture.
|
||||||
size_t _totalTextureBytes;
|
size_t _bytesPerInputPixel; // Determines per-pixel sizing within the write-area texture.
|
||||||
|
size_t _totalTextureBytes; // Holds the total size of the write-area texture.
|
||||||
|
|
||||||
|
// Textures: the frame buffer.
|
||||||
|
//
|
||||||
|
// When inter-frame blending is in use, the frame buffer contains the most recent output.
|
||||||
|
// Metal isn't really set up for single-buffered output, so this acts as if it were that
|
||||||
|
// single buffer. This texture is complete 2d data, copied directly to the display.
|
||||||
id<MTLTexture> _frameBuffer;
|
id<MTLTexture> _frameBuffer;
|
||||||
MTLRenderPassDescriptor *_frameBufferRenderPass;
|
MTLRenderPassDescriptor *_frameBufferRenderPass; // The render pass for _drawing to_ the frame buffer.
|
||||||
|
|
||||||
id<MTLTexture> _compositionTexture;
|
// Textures: the stencil.
|
||||||
MTLRenderPassDescriptor *_compositionRenderPass;
|
//
|
||||||
|
// Scan targets recceive scans, not full frames. Those scans may not cover the entire display,
|
||||||
// The stencil buffer and the two ways it's used.
|
// either because unlit areas have been omitted or because a sync discrepancy means that the full
|
||||||
|
// potential vertical or horizontal width of the display isn't used momentarily.
|
||||||
|
//
|
||||||
|
// In order to manage inter-frame blending correctly in those cases, a stencil is attached to the
|
||||||
|
// frame buffer so that a clearing step can darken any pixels that weren't naturally painted during
|
||||||
|
// any frame.
|
||||||
id<MTLTexture> _frameBufferStencil;
|
id<MTLTexture> _frameBufferStencil;
|
||||||
id<MTLDepthStencilState> _drawStencilState; // Always draws, sets stencil to 1.
|
id<MTLDepthStencilState> _drawStencilState; // Always draws, sets stencil to 1.
|
||||||
id<MTLDepthStencilState> _clearStencilState; // Draws only where stencil is 0, clears all to 0.
|
id<MTLDepthStencilState> _clearStencilState; // Draws only where stencil is 0, clears all to 0.
|
||||||
|
|
||||||
// The composition pipeline, and whether it's in use.
|
// Textures: the composition texture.
|
||||||
BOOL _isUsingCompositionPipeline;
|
//
|
||||||
|
// If additional temporal processing is required (i.e. for S-Video and colour composite output),
|
||||||
|
// fragments from the write-area texture are assembled into the composition texture, where they
|
||||||
|
// properly adjoin their neighbours and everything is converted to a common clock.
|
||||||
|
id<MTLTexture> _compositionTexture;
|
||||||
|
MTLRenderPassDescriptor *_compositionRenderPass; // The render pass for _drawing to_ the composition buffer.
|
||||||
|
BOOL _isUsingCompositionPipeline; // Whether the composition pipeline is in use.
|
||||||
|
|
||||||
// The scan target in C++-world terms and the non-GPU storage for it.
|
// The scan target in C++-world terms and the non-GPU storage for it.
|
||||||
BufferingScanTarget _scanTarget;
|
BufferingScanTarget _scanTarget;
|
||||||
|
Loading…
Reference in New Issue
Block a user