From 6345a7ba447d3e04b939ead6fee44fe9201ec2e3 Mon Sep 17 00:00:00 2001 From: Richard Li Date: Thu, 19 Nov 2009 16:05:43 -0500 Subject: [PATCH] r600 : check in shader code test enable flag: if flag R600_ENABLE_GLSL_TEST defined, IL shader code will goto r600 assembler. The test base is /mesa/progs/glsl/brick, and changes shader code in CH06-brick.frag/vert to test different logic op combination. (if,else,while,function,...). The stack depth code is not in yet, so it is hard coded now. So complex code would not run (such as things like 8 loops embeded loop in loop). --- src/mesa/drivers/dri/r600/r600_context.c | 54 ++++++++++++++++++++-- src/mesa/drivers/dri/r600/r700_assembler.c | 44 +++++++++++------- 2 files changed, 77 insertions(+), 21 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index dbd233729c0..ca0a670f3c3 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -72,7 +72,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vblank.h" #include "utils.h" -#include "xmlpool.h" /* for symbolic values of enum-type options */ +#include "xmlpool.h" /* for symbolic values of enum-type options */ + +//#define R600_ENABLE_GLSL_TEST 1 #define need_GL_VERSION_2_0 #define need_GL_ARB_occlusion_query @@ -154,8 +156,12 @@ static const struct dri_extension mm_extensions[] = { * The GL 2.0 functions are needed to make display lists work with * functions added by GL_ATI_separate_stencil. */ -static const struct dri_extension gl_20_extension[] = { - {"GL_VERSION_2_0", GL_VERSION_2_0_functions }, +static const struct dri_extension gl_20_extension[] = { +#ifdef R600_ENABLE_GLSL_TEST + {"GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, +#else + {"GL_VERSION_2_0", GL_VERSION_2_0_functions }, +#endif /* R600_ENABLE_GLSL_TEST */ }; static const struct tnl_pipeline_stage *r600_pipeline[] = { @@ -306,7 +312,28 @@ static void r600InitGLExtensions(GLcontext *ctx) driInitExtensions(ctx, card_extensions, GL_TRUE); if (r600->radeon.radeonScreen->kernel_mm) - driInitExtensions(ctx, mm_extensions, GL_FALSE); + driInitExtensions(ctx, mm_extensions, GL_FALSE); + +#ifdef R600_ENABLE_GLSL_TEST + driInitExtensions(ctx, gl_20_extension, GL_TRUE); + //_mesa_enable_2_0_extensions(ctx); + //1.5 + ctx->Extensions.ARB_occlusion_query = GL_TRUE; + ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE; + ctx->Extensions.EXT_shadow_funcs = GL_TRUE; + //2.0 + ctx->Extensions.ARB_draw_buffers = GL_TRUE; + ctx->Extensions.ARB_point_sprite = GL_TRUE; + ctx->Extensions.ARB_shader_objects = GL_TRUE; + ctx->Extensions.ARB_vertex_shader = GL_TRUE; + ctx->Extensions.ARB_fragment_shader = GL_TRUE; + ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE; + ctx->Extensions.EXT_blend_equation_separate = GL_TRUE; + ctx->Extensions.ATI_separate_stencil = GL_TRUE; + + /* glsl compiler has problem if this is not GL_TRUE */ + ctx->Shader.EmitCondCodes = GL_TRUE; +#endif /* R600_ENABLE_GLSL_TEST */ if (driQueryOptionb (&r600->radeon.optionCache, "disable_stencil_two_side")) @@ -341,7 +368,24 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual, assert(glVisual); assert(driContextPriv); - assert(screen); + assert(screen); + + //richard test + FILE *pFile = NULL; + unsigned long ulByteToWrite = 0; + char szStr[1024]; + + pFile = fopen("//home//richard//rtp-log//func_call.log", "a+"); + if(NULL != pFile) + { + sprintf(szStr, "r600CreateContext \r\n"); + ulByteToWrite = strlen(szStr); + fwrite(szStr, 1, ulByteToWrite, pFile); + + fclose(pFile); + pFile = NULL; + } + //------------- /* Allocate the R600 context */ r600 = (context_t*) CALLOC(sizeof(*r600)); diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 6e8d1cd9270..16ac920f293 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -4983,17 +4983,31 @@ GLboolean assemble_EXPORT(r700_AssemblerBase *pAsm) inline void checkStackDepth(r700_AssemblerBase *pAsm, GLuint uReason) { - switch (uReason) - { - case FC_PUSH_VPM: - break; - case FC_PUSH_WQM: - break; - case FC_LOOP: - break; - case FC_REP: - break; - }; + switch (uReason) + { + case FC_PUSH_VPM: + pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.pushs++; + pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.current++; + break; + case FC_PUSH_WQM: + pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.pushs++; + pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.current += 4; + break; + case FC_LOOP: + pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.pushs += 4; + break; + case FC_REP: + /* TODO : for 16 vp asic, should += 2; */ + pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.pushs += 1; + break; + }; + + if(pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.pushs + > pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.max) + { + pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.max = + pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.su.pushs; + } } GLboolean jumpToOffest(r700_AssemblerBase *pAsm, GLuint pops, GLint offset) @@ -5092,10 +5106,6 @@ GLboolean assemble_IF(r700_AssemblerBase *pAsm, GLboolean bHasElse) GLboolean assemble_ELSE(r700_AssemblerBase *pAsm) { -#ifdef USE_CF_FOR_POP_AFTER - pops(pAsm, 1); -#endif /* USE_CF_FOR_POP_AFTER */ - if(GL_FALSE == add_cf_instruction(pAsm) ) { return GL_FALSE; @@ -5647,7 +5657,9 @@ GLboolean testFlag(r700_AssemblerBase *pAsm) { return GL_FALSE; } -#endif +#endif + + checkStackDepth(pAsm, FC_PUSH_VPM); return GL_TRUE; } -- 2.30.2