Posts

Showing posts from March, 2018

Compilation & Execution

Image
C Program Compilation & Execution The C’s program building process involves four stages: Preprocessing  is the first pass of any C compilation. It processes include-files, conditional compilation instructions and macros. Compilation  is the second pass. It takes the output of the preprocessor, and the source code, and generates assembler source code. Assembly  is the third stage of compilation. It takes the assembly source code and produces an assembly listing with offsets. The assembler output is stored in an object file. Linking  is the final stage of compilation. It takes one or more object files or libraries as input and combines them to produce a single (usually executable) file. In doing so, it resolves references to external symbols, assigns final addresses to procedures/functions and variables, and revises code and data to reflect new addresses (a process called relocation). OBJECT FILES and EXECUTABLE After the source code has

Opengl-es Buffer

Image
Framebuffer A  Framebuffer  is a collection of buffers that can be used as the destination for rendering. OpenGL has two kinds of framebuffers: the  Default Framebuffer , which is provided by the  OpenGL Context ; and user-created framebuffers called  Framebuffer Objects  (FBOs). The buffers for default framebuffers are part of the context and usually represent a window or display device. The buffers for FBOs reference images from either  Textures  or  Renderbuffers ; they are never directly visible. Default Framebuffer The Default Framebuffer is the Framebuffer that OpenGL is created with. It is created along with the OpenGL Context. Like Framebuffer Objects , the default framebuffer is a series of images. Unlike FBOs, one of these images usually represents what you actually see on some part of your screen. Framebuffer Object FBO contains a collection of rendering destinations; color, depth and stencil buffer. These logical buffers in a FBO are called framebuffer-attachab

GPU Pipeline

Image
Graphics Pipeline Geometry and primitives Typically, An application is the place where we want to define the geometry that we want to render to the screen. This geometry can be defined by points, lines, triangles, quads, triangle strips... These are so called  geometric primitives.  These points will then reside in system memory.  Your application will use the 3D API to transfer the defined vertices from system memory into the GPU memory.  Vertices So we'll have a vertex that contains location, as well as color information. Vertex shaders A "pass-through" vertex shader will take the shader inputs and will pass these to its output without modifying these: the vertices P1, P2 and P3 from the triangle are fetched from memory, each individual vertex is fed to vertex shader instances which run in parallel.  Vertex processing computes the  normalized coordinate space position  of vertices.  The outputs from the vertex shaders are fed into the  primitive assem

CPU Pipeline

Image
History of CPU Pipeline The original 8086 processor has 14 CPU registers which are still in use today. Four are general purpose registers -- AX, BX, CX, and DX. Four are segment registers that are used to help with pointers -- Code Segment (CS), Data Segment (DS), Extra Segment (ES), and Stack Segment (SS). Four are index registers that point to various memory locations -- Source Index (SI), Destination Index (DI), Base Pointer (BP), and Stack Pointer (SP). The instruction pointer’s job is to point to the next instruction to be run. First, they follow the instruction pointer and decode the next CPU instruction at that location. After decoding, there is an execute stage where the instruction is run. Some instructions read from memory or write to it, others perform calculations or comparisons or do other work. When the work is done, the instruction goes through a retire stage and the instruction pointer is modified to point to the next instruction.  In 1982 an instruction c

Opengl Stages of Vertex Transformation

Image
Stages of Vertex Transformation Required to render the desired scene of a 3d world in a 2d screen Object Coordinates : local coordinate system of object before any transformation is applied. Eye coordinates : the result of multiplication of GL_MODELVIEW matrix and object coordinates. Objects are transformed from object space to eye space. M(ModelView) = M(view). M(model) where M(model) = object space to world space and M(view) = world space to eye space. Clip coordinates : the result of multiplication of GL_PROJECTION matrix and eye coordinates. GL_PROJECTION matrix used to define the frustum. It determined hot the 3D scene is projected onto the screen. NDC : Perspective division which is yielded by dividing the clip coordinates by w. Window coordinates : NDC are scaled and translated in order to fit into the rendering screen. Analogy With a Camera Transformations : Viewing Transformation : Setting up tripod and pointing the camera at the scene.