Changeset 405

Show
Ignore:
Timestamp:
06/02/07 06:45:33 (16 months ago)
Author:
krobillard
Message:

Thune GL - Added samples-query.

Location:
branches/thune/thread_safe
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • branches/thune/thread_safe/gl/boot.c

    r403 r405  
    100100  "    shadow-begin\n" 
    101101  "    shadow-end\n" 
     102  "    samples-query\n" 
     103  "    samples-begin\n" 
    102104  "]\n" 
    103105  "make-opcodes :draw-list-opcodes\n" 
     
    149151  "] func :load.tex.clamp\n" 
    150152  "#[\n" 
    151   "    1.0 0.0 0.0 0.0\n" 
    152   "    0.0 1.0 0.0 0.0\n" 
    153   "    0.0 0.0 1.0 0.0\n" 
    154   "    0.0 0.0 0.0 1.0\n" 
     153  "    1.0 0.0 0.0 0.0 \n" 
     154  "    0.0 1.0 0.0 0.0 \n" 
     155  "    0.0 0.0 1.0 0.0 \n" 
     156  "    0.0 0.0 0.0 1.0 \n" 
    155157  "] :unit-matrix\n" 
    156158  "[\n" 
  • branches/thune/thread_safe/gl/draw_list.c

    r403 r405  
    7575    _state.attr[0].vals = 0; 
    7676    _state.attr[1].vals = 0; 
     77    _state.samplesQueryId = 0; 
    7778} 
    7879 
     
    132133            { 
    133134                glDepthMask( GL_FALSE ); 
     135 
     136            //glEnable( GL_DEPTH_TEST ); 
    134137 
    135138                glDisable( GL_ALPHA_TEST ); 
     
    345348    } 
    346349} 
     350 
     351 
     352//---------------------------------------------------------------------------- 
     353 
     354 
     355#if 0 
     356GLuint gr_querySamples() 
     357{ 
     358    GLuint sampleCount; 
     359    //const GLuint id = 1; 
     360    int id; 
     361    int endId = 1 + 1; 
     362 
     363#if 0 
     364    // 32 bits on GeForce 6600 GT 
     365    GLint bits; 
     366    glGetQueryiv( GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &bits ); 
     367    printf( "KR GL_QUERY_COUNTER_BITS = %d\n", bits ); 
     368#endif 
     369 
     370    glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); 
     371    glDepthMask( GL_FALSE ); 
     372 
     373    for( id = 1; id < endId; ++id ) 
     374    { 
     375        glBeginQuery( GL_SAMPLES_PASSED, id ); 
     376 
     377        // Draw... 
     378 
     379        glEndQuery( GL_SAMPLES_PASSED ); 
     380    } 
     381 
     382    //glFlush(); 
     383 
     384    glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); 
     385    glDepthMask( GL_TRUE ); 
     386 
     387    for( id = 1; id < endId; ++id ) 
     388    { 
     389        glGetQueryObjectuiv( id, GL_QUERY_RESULT, &sampleCount ); 
     390        //printf( "KR GL_QUERY_RESULT = %d\n", sampleCount ); 
     391    } 
     392 
     393    return sampleCount; 
     394} 
     395#endif 
    347396 
    348397 
     
    792841        { 
    793842            case DOP_NOP: 
     843                //printf( "KR DL NOP\n" ); 
    794844                break; 
    795845 
     
    858908                    case UR_ATOM_SPRITE: 
    859909                        gr_setState( GRS_PARTICLE ); 
    860                         glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 
     910                        //glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 
     911                        //glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); 
     912                        glBlendFunc( GL_SRC_ALPHA, GL_ONE ); 
    861913                        glEnable( GL_POINT_SPRITE ); 
    862914                        break; 
     
    10851137                break; 
    10861138 
     1139            case DOP_SAMPLES_QUERY:     // dlist-block process-block 
     1140                ++pc; 
     1141                if( ! ur_is(pc, UT_BLOCK) ) 
     1142                    return 0; 
     1143 
     1144                _state.samplesQueryId = 0; 
     1145 
     1146                glEnable( GL_CULL_FACE ); 
     1147                glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); 
     1148                glDepthMask( GL_FALSE ); 
     1149 
     1150                // Run draw-list containing samples-begin ops. 
     1151                if( ! _runDrawList( ut, pc ) ) 
     1152                    return 0; 
     1153 
     1154                if( _state.samplesQueryId ) 
     1155                    glEndQuery( GL_SAMPLES_PASSED ); 
     1156 
     1157                glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); 
     1158                glDepthMask( GL_TRUE ); 
     1159 
     1160                ++pc; 
     1161                if( ur_is(pc, UT_BLOCK) ) 
     1162                { 
     1163                    GLuint samples; 
     1164                    GLuint id; 
     1165                    //UBinary* bin; 
     1166                    //UIndex binN; 
     1167 
     1168                    // Push query results on stack and call process-block. 
     1169 
     1170                    //bin = ur_binaryPtr( binN ); 
     1171 
     1172                    for( id = 1; id <= _state.samplesQueryId; ++id ) 
     1173                    { 
     1174                        glGetQueryObjectuiv( id, GL_QUERY_RESULT, &samples ); 
     1175                        //printf( "KR samples %d %d\n", id, samples ); 
     1176 
     1177                        UR_S_GROW; 
     1178                        ur_initType( UR_TOS, UT_INT ); 
     1179                        ur_int(UR_TOS) = samples; 
     1180                    } 
     1181 
     1182                    if( ur_eval( ut, pc->series.n, pc->series.it ) 
     1183                        != UR_EVAL_OK ) 
     1184                        return 0; 
     1185                } 
     1186 
     1187                _state.samplesQueryId = 0; 
     1188                break; 
     1189 
     1190            case DOP_SAMPLES_BEGIN: 
     1191                if( _state.samplesQueryId ) 
     1192                    glEndQuery( GL_SAMPLES_PASSED ); 
     1193 
     1194                ++_state.samplesQueryId; 
     1195                glBeginQuery( GL_SAMPLES_PASSED, _state.samplesQueryId ); 
     1196                break; 
     1197 
    10871198            default: 
    10881199                assert( 0 && "Invalid Draw List Opcode" ); 
  • branches/thune/thread_safe/gl/draw_ops.h

    r383 r405  
    3737#define DOP_SHADOW_BEGIN    34 
    3838#define DOP_SHADOW_END      35 
     39#define DOP_SAMPLES_QUERY   36 
     40#define DOP_SAMPLES_BEGIN   37 
  • branches/thune/thread_safe/gl/gx.h

    r390 r405  
    144144 
    145145    GrVertexAttribute attr[2]; 
     146    GLuint samplesQueryId; 
    146147}; 
    147148 
  • branches/thune/thread_safe/gl/gx.t

    r403 r405  
    165165    shadow-begin 
    166166    shadow-end 
     167 
     168    samples-query 
     169    samples-begin 
    167170] 
    168171make-opcodes :draw-list-opcodes 
  • branches/thune/thread_safe/gl/scripts/view.t

    r403 r405  
    6610,0,10 :bg-color 
    77;off key-repeat 
     80.0,0 :win-size 
     9 
     10"shader/matte.gx" load.shader :matte 
    811 
    912"scripts/stars.t" load do  400 make-stars :star-dl 
     
    1922"image/star.png" load.tex :bstar-sh/cmap 
    2023 
     24"shader/ship-lights.gx" load.shader :rlight-shader 
     25"image/lightFlareA.png" load.tex    :rlight-shader/cmap 
    2126 
    2227/* 
     
    7075    model-list   :d7-dl 
    7176    model-shader :d7-shader 
     77 
     78    "model/d7_lights.gx" load do 
    7279] :d7 
    7380 
     
    8390 
    84911024,1024 dup :smap-size shadowmap :light-fb 
    85 "shader/matte.gx" load.shader :smap-shader 
    8692camera [ 
    8793    ;'ortho 
     
    109115 
    110116d7  do  light-fb/texture :d7-shader/smap 
    111 ent do  light-fb/texture :ent-shader/smap 
     117;ent do  light-fb/texture :ent-shader/smap 
    112118 
    113119 
     
    177183        dup :view-cam/viewport 
    178184 
     185        /* 
     186        area/3 :win-size/x 
     187        area/4 :win-size/y 
     188        win-size :rlight-shader/windowsize 
     189        */ 
    179190        ;vec3! [area/3 area/4] reduce make :star-sh/windowsize 
    180191    ] 
     
    196207        camera light-cam 
    197208        shadow-begin light-fb 
    198         shader smap-shader 
     209        shader matte 
    199210        call model-list 
    200211        camera view-cam 
     
    226237        shader model-shader 
    227238        call model-list 
    228         shader none 
    229  
     239        ;shader none 
     240 
     241/* 
     242*/ 
     243        shader matte 
     244        call d7-lights-query 
     245        particle/sprite 
     246            shader rlight-shader call d7-lights 
     247        particle/off 
    230248 
    231249        ;ortho-cam 
  • branches/thune/thread_safe/urlan.h

    r403 r405  
    600600 
    601601UIndex ur_hold( UThread*, int type, UIndex which ); 
    602 UIndex ur_holdIndex( UThread*, UIndex ); 
    603602void   ur_release( UThread*, UIndex ); 
    604603