From e5e49de8c655b93733fc2959f2bb4ee69c9c09a3 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 23 Jun 2012 00:10:31 +0200 Subject: [PATCH] moco on I frames working --- glmocoshader.cc | 114 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 93 insertions(+), 21 deletions(-) diff --git a/glmocoshader.cc b/glmocoshader.cc index 22c0eb2..23fcc61 100755 --- a/glmocoshader.cc +++ b/glmocoshader.cc @@ -37,10 +37,13 @@ const GLchar moco_vertex_shader[] = "varying vec4 out_yblockpos_y;\n" "varying vec4 out_uvblockpos_xy;\n" "varying vec2 out_block_edge;\n" + "varying vec4 out_block_types;\n" "const float one=1.0;\n" "const float c1024=1024.0;\n" "const float c32=32.0;\n" + // "const float c1over32=0.03125;\n" + "const float c1over32=1./32.;\n" "const float c65536=65536.;\n" @@ -55,6 +58,7 @@ const GLchar moco_vertex_shader[] = " vec4 cbp_vec=vec4(cbp,cbp,cbp,cbp);\n" " vec4 fmod_cbp_y=mod(cbp_vec,y_cbp);\n" " vec2 fmod_cbp_uv=mod(cbp_vec.xy,uv_cbp);\n" + " fmod_cbp_y.x=0.;\n" " fmod_cbp_y=sign(vec4(fmod_cbp_y.yzw,fmod_cbp_uv.x)-fmod_cbp_y);\n" " fmod_cbp_uv=sign(vec2(fmod_cbp_uv.y,cbp)-fmod_cbp_uv);\n" // resulting vector should indicate with block is present @@ -68,13 +72,20 @@ const GLchar moco_vertex_shader[] = " fmod_cbp_uv2.y+=fmod_cbp_uv2.x;\n" // now calculate their position inside the short array - " float m_index=index.x+index.y*c65536;\n" //Not Endian save + " float m_index=index.x/*+index.y*c65536*/-one;\n" //Not Endian save " fmod_cbp_y2+=m_index;\n" //shift to the blocks " fmod_cbp_uv2+=m_index;\n" - " out_yblockpos_x=mod(fmod_cbp_y2,c32);\n" - " out_uvblockpos_xy.xy=mod(fmod_cbp_uv2,c32);\n" - " out_yblockpos_y=floor((fmod_cbp_y2)/c32);\n" - " out_uvblockpos_xy.zw=floor((fmod_cbp_uv2)/c32);\n" + //" out_yblockpos_x=(mod(fmod_cbp_y2,c32));\n" + //" out_uvblockpos_xy.xy=(mod(fmod_cbp_uv2,c32));\n" + //" out_yblockpos_y=floor((fmod_cbp_y2)/c32);\n" + //" out_uvblockpos_xy.zw=floor((fmod_cbp_uv2)/c32);\n" + + " out_yblockpos_y=floor((fmod_cbp_y2)*c1over32);\n" + " out_uvblockpos_xy.zw=floor((fmod_cbp_uv2)*c1over32);\n" + " out_yblockpos_x=fmod_cbp_y2-c32*out_yblockpos_y;\n" + " out_uvblockpos_xy.xy=fmod_cbp_uv2-c32*out_uvblockpos_xy.zw;\n" + + //Kick out uncoded blocks " out_yblockpos_y-=sign(fmod_cbp_y-one)*c1024;\n" @@ -82,6 +93,7 @@ const GLchar moco_vertex_shader[] = " out_block_edge=block_edge;\n" + " out_block_types=block_types;\n" " vec4 out_pos=block_pos;\n" " out_pos.xy+=block_edge;\n" " out_pos.xy*=pict_scale;\n" @@ -97,14 +109,17 @@ const GLchar moco_frag_shader[] = "varying vec4 out_yblockpos_y;\n" "varying vec4 out_uvblockpos_xy;\n" "varying vec2 out_block_edge;\n" + "varying vec4 out_block_types;\n" + "const float halfst=0.5;\n" "const float ctwo=2.0;\n" + "const float cone=1.0;\n" "const float sieben=7.0;\n" "const float acht=8.0;\n" "const float s8=1./8.;\n" "const float s16=1./16.;\n" - "const float c1over2047=1./2047.;\n" - "const float c1over1023=1./1023.;\n" + "const float c1over2048=1./2048.;\n" + "const float c1over1024=1./1024.;\n" "const float c255=255.;\n" "const float c65280=65280.;\n" "const float c65536=65536.;\n" @@ -122,25 +137,82 @@ const GLchar moco_frag_shader[] = "{\n" // first figure out the block num for y, first decide between up and down, fix me field //non field code - // " vec4 ypos_temp1=mix(vec4(out_yblockpos_x.x,out_yblockpos_y.x,out_yblockpos_x.y,out_yblockpos_y.y)," + " vec4 ypos_temp1;\n" + " bool upper_half;\n" + " float line_step;\n" + " if (out_block_types.w!=0.) {\n" //test the dct type + " upper_half=mod(floor(out_block_edge.y*acht),ctwo)==cone;\n" + " line_step=cone;\n" + "}else{\n" + " upper_half=halfsthalfst);\n" + " bool subsample=mod(ypos_temp3.x,ctwo)==cone;\n" + " ypos_temp2.x*=halfst;\n" + " ypos_temp2.xy*=c1over1024;\n" + " ypos_temp1=texture2D(blocks,ypos_temp2.xy);\n" // now select the right data + "if (subsample){\n" + " ypos_temp2.xy=ypos_temp1.zw;\n" + //" ypos_temp2=vec2(cone,0.);\n" + " }else {\n" + " ypos_temp2.xy=ypos_temp1.xy;\n" + " }\n" + " gl_FragColor.r=unpack_short(ypos_temp2.rg);\n" + + //now uv + " ypos_temp3=floor(out_block_edge*acht);\n" + " ypos_temp2.yw=floor(out_uvblockpos_xy.zw);\n" + " ypos_temp2.xz=(ypos_temp3.x+(ypos_temp3.y+acht*(out_uvblockpos_xy.xy))*acht);\n" + //" bool subsample=(mod(ypos_temp2.x,ctwo)>halfst);\n" + " subsample=mod(ypos_temp3.x,ctwo)==cone;\n" + " ypos_temp2.xz*=halfst;\n" + " ypos_temp2*=c1over1024;\n" + + " ypos_temp1=texture2D(blocks,ypos_temp2.xy);\n" // now select the right data + " if (subsample){\n" + " ypos_temp2.xy=ypos_temp1.zw;\n" + " }else {\n" + " ypos_temp2.xy=ypos_temp1.xy;\n" + " }\n" + " gl_FragColor.g=unpack_short(ypos_temp2.rg);\n" + + " ypos_temp1=texture2D(blocks,ypos_temp2.zw);\n" // now select the right data + " if (subsample){\n" + " ypos_temp2.xy=ypos_temp1.zw;\n" + " }else {\n" + " ypos_temp2.xy=ypos_temp1.xy;\n" + " }\n" + " gl_FragColor.b=unpack_short(ypos_temp2.rg);\n" + + + //" ypos_temp2=mix(ypos_temp1.rg,ypos_temp1.ba,step(c1over2047,mod(ypos_temp2.x,c1over1023)));\n" //activate this + + + //" gl_FragColor.r=subsample/acht;\n" //signed later TODO + //" gl_FragColor.g=0.5;\n" + //" gl_FragColor.b=0.5;\n" " gl_FragColor.a=1.0;\n" //" vec4 blocks=texture2D(blocks,gl_FragCoord.xy/600.);\n" // "help.x=texture2D(textureY,out_texCoord).r;\n" -- 2.39.2