320 likes | 414 Views
Status – Week 257. Victor Moya. Summary. GPU interface. GPU state. API/Driver State. Driver/CPU Proxy. Command Processor. Imagine. GPU Interface. The GPU chip interfaces with: AGP port. Local (video) memory.
E N D
Status – Week 257 Victor Moya
Summary • GPU interface. • GPU state. • API/Driver State. • Driver/CPU Proxy. • Command Processor. • Imagine.
GPU Interface • The GPU chip interfaces with: • AGP port. • Local (video) memory. • Output video signal (as DAC is integrated it is already raw digital or analog video signal). • Input Video signal (TV/Video capture). • We can ignore the output/input video signals. • Local memory is only accessed by the GPU chip. It can use any standard DRAM interface.
GPU Interface Local Memory AGP Port Video Output Video Input
GPU Interface: AGP Interface • GPU is connected through the AGP port to the CPU and main memory. • The CPU can issue commands, read and write data from/to the GPU through the AGP. • The GPU can read data and write data through the AGP.
GPU Interface: AGP Interface • DMA can be used to read/write from/to the main memory to/from the video memory through the AGP. • The GPU can send IRQs to the CPU. • AGP can map main memory pages to the GPU (graphic overture).
GPU Interface: AGP Interface • Intel describes the logical and physical (signaling) protocol for the AGP port. • Based in the PCI bus. • Transactions: • Read. • Write. • Control? • Do we need to simulate the AGP protocol?
GPU Interface: AGP Interface • What do we need? • Data written to GPU local memory: • textures • vertex buffers • index buffers • display lists? • Data read from GPU local memory: • textures (render targets). • framebuffer: color + Z + stencil.
GPU Interface: AGP Interface • What do we need? • Data read from the main memory: • AGP textures. • API/Driver buffers in system memory? • Data written to the main memory: • ??
GPU Interfaces: AGP Interface • What do we need? • Control: • GPU commands: • Initialize display (resolution, viewport, pixel format …). • Start frame/end frame. • Draw batch (vertex buffer, indexed buffer, …).
GPU Interface:AGP Interface • What do we need? • Control: • GPU state changes: • Primitive mode. • Clip planes. • Vertex shader program and vertex shader state. • Rasterization options • Texture state. • Pixel shader program and pixel shader state. • Fragment/Color state (color, Z, Stencil, fog, alpha, scissor, …). • Etc.
GPU Interface: AGP Interface. • What do we need? • Signaling (IRQ) to the API/Driver? • End of DMA transfer?
GPU Interface • Simple GPU interface: • Write to GPU memory. • Read from GPU memory. • Write GPU state. • Read GPU state. • Issue GPU command. • IRQ signal? • Termination: read/write, command.
GPU Interface • Write to GPU memory: • Address, size, data -> • Read from GPU memory: • Address, size -> data • Write GPU state: • register, value -> • Read GPU state: • register -> value • Issue GPU command: • command, parameter list ->
GPU Interface • Registers: • ViewPort Res X: screen resolution (INT). • ViewPort Res Y: screen resolution (INT). • Pixel Mode: bits per pixel, etc (PXFORMAT). • Color Buffer Address: local memory address for the color buffer (UINT). • Z/Stencil Buffer Address: local memory address for the Z and Stencil buffers (UINT). • Texture Memory Address: local memory address for the texture buffers (UINT)? • Program Memory Address: local memory address for the shader program buffers (UINT)?
GPU Interface • Registers: • Clear Color: color buffer clear color (QF). • Primitive Mode: TRIANGLE, TRIANGLE STRIP, TRIANGLE FAN, POINT?, LINE?, LINE STRIP?, LINE FAN?. • Interpolation (shading?) Mode: FLAT, LINEAR. • Vertex Shader Program: vertex program ID/address (UINT). • Vertex Shader Constants: vertex program constants (QF[], QI []?, B[]?, I[]?).
GPU Interface • Registers: • Vertex Stream0-n: ID/address to the current vertex buffer stream (UINT). • Vertex Stream Size0-n: Size of the stream (UINT). • Vertex Stream Stride0-n: stride of the stream (UINT). • Vertex Stream Mapping0-n: mapping to the vertex shader input registers. • Index Stream: ID/address to the current vertex buffer stream (UINT). • Index Stream Size: size of the stream (UINT).
GPU Interface • Registers: • Clip Plane Left: left clip plane (FLOAT). • Clip Plane Right: right clip plane (FLOAT). • Clip Plane Top: top clip plane (FLOAT). • Clip Plane Bottom: bottom clip plane (FLOAT). • Clip Plane Near: near clip plane (FLOAT). • Clip Plane Far: far clip plane (FLOAT). • User Clip Planes0-n: User volume clip planes (QF). • Culling Mode: NONE, FRONT, BACK, FRONT_BACK.
GPU Interface • Registers: • Multisampling related registers (?). • Supersampling related registers (?). • Point related registers (?). • Line related registers (?). • Zbias/Depth Offset: ?
GPU Interface • Registers: • Texture related registers (?). • Pxel shader related state: • Pixel shader program: pixel shader program ID/address (UINT). • Pixel shader constants: pixel shader constant bank (QF[]). • Fog related registers (?).
GPU Interface • Registers: • Scissor test related registers (?). • Alpha test related registers (?). • Stencil test related registers (?). • Depth test related registers (?). • Blending related registers (?). • Others (?).
GPU Interface • Commands: • Reset: reset of the GPU. • No parameters: • Clear: clears all buffers? • No parameters. • SwapBuffer: changes the display (front) buffer. • No parameters?. • DrawBatch: draws a vertex batch (array). • No parameters (if the info is in the GPU registers). • DrawIndexedBatch: draw an indexed vertex batch. • No parameters (if the info is in the GPU registers).
GPU Interface • Commands: • Blit: local memory to local memory copy. • Source address • Target address.
GPU State • GPU control registers. • GPU status registers? • Queries. • End Of Frame. • Occlusion queries: number of pixels drawn.
GPU State • Rendering mode: • IMR: Immediate Mode Renderer. • Only stores current state (immediate). • Deferred Rendering. • Must store all state changes for the next frame. • Must have stored the current (drawing) frame. • Perhaps some permanent state (resolution?). • Storage: • Local memory (Bin). • System memory (driver).
API/Driver State • OpenGL: OpenGL specification has an appendix with all the OpenGL state variables. • DirectX: would need research. State based in COM objects.
API/Driver emulation • Must translate API calls (OpenGL) and API objects (DirectX) to GPU commands. • Read a trace file and translate to GPU commands (static). • Replace system API libraries (dlls, shared libs) and send commands to a GPU simulator (dynamic).
API/Driver emulation • First prototype for GLTrace traces: • Set initial state (resolution, etc). • Calculate the projection and model view matrix (multiplication). • Store the combinend matrix (multiplied) in the vertex shader constant memory. • Store the default transformation vertex shader program (vertex x matrix). • Translate glRectf into two triangles.
API/Driver Emulation • Store vertex and vertex parameters between glBegin and glEnd functions. • Issue vertex and vertex parameters to the GPU. • Set other rasterization and fragment parameters for the OpenGL stub.
API/Driver Emulation • Future development: • Add lightning and material state: store in vertex shader constant bank. • Create lightning vertex program. • Support DrawElements and other vertex array and index based rendering modes.
Command Processor • Stores all or part of the GPU state. • GPU state can be replicated in the different sections of the GPU (geometry, rasterization, fragment). • Receives commands from the main system (API/driver). • Interprets and issues those commands to the GPU units.
Imagine • ‘Computer Graphics on a Stream Architecture’, John Douglas Owens, PhD dissertation. • Not read yet either.