Программирование графических процессоров

  • Published on
    30-Dec-2015

  • View
    32

  • Download
    0

Embed Size (px)

DESCRIPTION

. , . 3D -. . 3. : . : . . : 1D, 2D, 3D - - PowerPoint PPT Presentation

Transcript

  • ,

  • 3D-

    *----------

  • *

    INPUT-ASSEMBLERSTAGETriangles, Lines, Points

    VERTEX SHADER STAGEper-vertex processing

    GEOMETRYSHADERSTAGEproduces new geometry

    RASTERIZERSTAGEclipping, prep to pixel shaders

    PIXELSHADERSTAGEgenerates per-pixel data

    OUTPUT MERGERSTAGEblending, depth, stencil

  • :

    *----------

  • :

    *----------

  • : 1D, 2D, 3D- Cube- : : Lum, RGB, RGBA . : Byte, Int16, Float16, Float32

    : Wrap, Clamp, Border, Mirror

    : Nearest, Linear, Mipmap, Anisotropic

    *----------

  • (asm):HLSL- Direct3D 9 10Cg- OpenGL, Direct3DGLSL- OpenGL

    *----------

  • (HLSL, Cg):float, half, int, bool:float2, float3, float4:float2x2 float4x4:sampler2D, sampler3D etc

    :uniform, static etc

    :COLOR, NORMAL, POSITION etc

    *----------

  • :+ - * / mad(), dot(), cross(), reflect()sin(), cos(), pow()saturate(), clamp(), step()floor(), ceil()

    ( ):tex2D, tex3D, texCUBE, tex2Dlod, tex2Dgrad, tex2Dproj

    *----------

  • float4 a; float4 b(1,2,3,4); float4 c = 1; // = float4(1,1,1,1);

    a = b; a.x = b.y; a.xyzw = b.wzxy;// //

    for, if, while, do- ,

    *----------

  • x, ytex2D( sampler, float2(x, y) );tex1D( sampler, float(x) );tex3D( sampler, float3(x, y, z) );x, y, z

    *----------

  • float4 DoSomething( in float3 a, out float2 b, inout float4 c) { b.xy = a.xz; c.xyz = a.zzy; c.w = dot(c.xyz, a.xyz);return float4(1,2,3,4); }

    *----------

  • uniform float4x4 world_matrix : register (c1);uniform float4 color_mul : register (c5);uniform sampler input_data : register (s1);

    PS_OUT PSMain(in VS_OUT input) {PS_OUT output;output.color = tex2D(input_data, input.tex0.xy);output.color *= color_mul;return out;}

    *----------

  • ( )Vertex Shaderstruct VS_IN { float3 pos : POSITION; float2 tex : TEXCOORD0; float4 clr : COLOR0; float3 norm : NORMAL; };

    struct VS_OUT { float4 pos : POSITION; float2 tex : TEXCOORD0; float4 clr : COLOR0; };

    POSITION Pixel Shaderstruct PS_IN { //float4 pos : POSITION; float2 tex : TEXCOORD0; float4 clr : COLOR0; };

    struct PS_OUT { float4 color : COLOR0; float depth : DEPTH; };

    *----------

  • ( )VS: VS_OUT VSMain(VS_IN input) { VS_OUT output; // return output; }PS: PS_OUT PSMain(VS_OUT input) { PS_OUT output; // return out; }

    *----------

  • INPUT ASSEMBLERPOSITIONCOLORNORMALTEXCOORDNew POSITIONNew COLORNew TEXCOORD

    RASTERIZER Geometry ShaderVSMainVSMainVSMainShaderConsts

    *----------

  • VS_OUT #1VS_OUT #3VS_OUT #2PSMainPS_INRASTERIZER ShaderConsts

    *----------

  • *----------

    TEXTURE

    TEXTURES

    RENDERTARGET

    PIXELSHADER

    TEXTURES

    SHADER CONSTANTS(UNIFORMS)

  • demo_imgproc.fx

    demo_sci.fx

    demo_mri.fx*

  • (demo_imgproc.fx)

    *----------

  • (demo_sci.fx)

    float value = tex3D(data, float3(x,y,z)).r;// return tex2D(pal, float2(value, 0));ddx(), ddy()

    if((s0h) || (s1h) || (s2h) || (s3h)) { sample = 1;} else { sample = 0;}

    *----------

  • (demo_mri.fx)

    *----------

Recommended

View more >