/*
* Mesa 3-D graphics library
* Version: 7.3
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* \file prog_print.c
* Print vertex/fragment programs - for debugging.
* \author Brian Paul
*/
#include <inttypes.h> /* for PRIx64 macro */
#include "main/glheader.h"
#include "main/context.h"
#include "main/imports.h"
#include "prog_instruction.h"
#include "prog_parameter.h"
#include "prog_print.h"
#include "prog_statevars.h"
/**
* Return string name for given program/register file.
*/
const char *
_mesa_register_file_name(gl_register_file f)
{
switch (f) {
case PROGRAM_TEMPORARY:
return "TEMP";
case PROGRAM_LOCAL_PARAM:
return "LOCAL";
case PROGRAM_ENV_PARAM:
return "ENV";
case PROGRAM_STATE_VAR:
return "STATE";
case PROGRAM_INPUT:
return "INPUT";
case PROGRAM_OUTPUT:
return "OUTPUT";
case PROGRAM_NAMED_PARAM:
return "NAMED";
case PROGRAM_CONSTANT:
return "CONST";
case PROGRAM_UNIFORM:
return "UNIFORM";
case PROGRAM_VARYING:
return "VARYING";
case PROGRAM_WRITE_ONLY:
return "WRITE_ONLY";
case PROGRAM_ADDRESS:
return "ADDR";
case PROGRAM_SAMPLER:
return "SAMPLER";
case PROGRAM_SYSTEM_VALUE:
return "SYSVAL";
case PROGRAM_UNDEFINED:
return "UNDEFINED";
default:
{
static char s[20];
_mesa_snprintf(s, sizeof(s), "FILE%u", f);
return s;
}
}
}
/**
* Return ARB_v/f_prog-style input attrib string.
*/
static const char *
arb_input_attrib_string(GLint index, GLenum progType)
{
/*
* These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens.
*/
static const char *const vertAttribs[] = {
"vertex.position",
"vertex.weight",
"vertex.normal",
"vertex.color.primary",
"vertex.color.secondary",
"vertex.fogcoord",
"vertex.(six)", /* VERT_ATTRIB_COLOR_INDEX */
"vertex.(seven)", /* VERT_ATTRIB_EDGEFLAG */
"vertex.texcoord[0]",
"vertex.texcoord[1]",
"vertex.texcoord[2]",
"vertex.texcoord[3]",
"vertex.texcoord[4]",
"vertex.texcoord[5]",
"vertex.texcoord[6]",
"vertex.texcoord[7]",
"vertex.(sixteen)", /* VERT_ATTRIB_POINT_SIZE */
"vertex.attrib[0]",
"vertex.attrib[1]",
"vertex.attrib[2]",
"vertex.attrib[3]",
"vertex.attrib[4]",
"vertex.attrib[5]",
"vertex.attrib[6]",
"vertex.attrib[7]",
"vertex.attrib[8]",
"vertex.attrib[9]",
"vertex.attrib[10]",
"vertex.attrib[11]",
"vertex.attrib[12]",
"vertex.attrib[13]",
"vertex.attrib[14]",
"vertex.attrib[15]" /* MAX_VARYING = 16 */
};
static const char *const fragAttribs[] = {
"fragment.position",
"fragment.color.primary",
"fragment.color.secondary",
"fragment.fogcoord",
"fragment.texcoord[0]",
"fragment.texcoord[1]",
"fragment.texcoord[2]",
"fragment.texcoord[3]",
"fragment.texcoord[4]",
"fragment.texcoord[5]",
"fragment.texcoord[6]",
"fragment.texcoord[7]",
"fragment.(twelve)", /* FRAG_ATTRIB_FACE */
"fragment.(thirteen)", /* FRAG_ATTRIB_PNTC */
"fragment.(fourteen)", /* FRAG_ATTRIB_CLIP_DIST0 */
"fragment.(fifteen)", /* FRAG_ATTRIB_CLIP_DIST1 */
"fragment.varying[0]",
"fragment.varying[1]",
"fragment.varying[2]",
"fragment.varying[3]",
"fragment.varying[4]",
"fragment.varying[5]",
"fragment.varying[6]",
"fragment.varying[7]",
"fragment.varying[8]",
"fragment.varying[9]",
"fragment.varying[10]",
"fragment.varying[11]",
"fragment.varying[12]",
"fragment.varying[13]",
"fragment.varying[14]",
"fragment.varying[15]",
"fragment.varying[16]",
"fragment.varying[17]",
"fragment.varying[18]",
"fragment.varying[19]",
"fragment.varying[20]",
"fragment.varying[21]",
"fragment.varying[22]",
"fragment.varying[23]",
"fragment.varying[24]",
"fragment.varying[25]",
"fragment.varying[26]",
"fragment.varying[27]",
"fragment.varying[28]",
"fragment.varying[29]",
"fragment.varying[30]",
"fragment.varying[31]", /* MAX_VARYING = 32 */
};
/* sanity checks */
STATIC_ASSERT(Elements(vertAttribs) == VERT_ATTRIB_MAX);
STATIC_ASSERT(Elements(fragAttribs) == FRAG_ATTRIB_MAX);
assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0);
assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0);
assert(strcmp(fragAttribs[FRAG_ATTRIB_TEX0], "fragment.texcoord[0]") == 0);
assert(strcmp(fragAttribs[FRAG_ATTRIB_VAR0+15], "fragment.varying[15]") == 0);
if (progType == GL_VERTEX_PROGRAM_ARB) {
assert(index < Elements(vertAttribs));
return vertAttribs[index];
}
else {
assert(progType == GL_FRAGMENT_PROGRAM_ARB);
assert(index < Elements(fragAttribs));
return fragAttribs[index];
}
}
/**
* Print a vertex program's InputsRead field in human-readable format.
* For debugging.
*/
void
_mesa_print_vp_inputs(GLbitfield inputs)
{
printf("VP Inputs 0x%x: \n", inputs);
while (inputs) {
GLint attr = ffs(inputs) - 1;
const char *name = arb_input_attrib_string(attr,
GL_VERTEX_PROGRAM_ARB);
printf(" %d: %s\n", attr, name);
inputs &= ~(1 << attr);
}
}
/**
* Print a fragment program's InputsRead field in human-readable format.
* For debugging.
*/
void
_mesa_print_fp_inputs(GLbitfield inputs)
{
printf("FP Inputs 0x%x: \n", inputs);
while (inputs) {
GLint attr = ffs(inputs) - 1;
const char *name = arb_input_attrib_string(attr,
GL_FRAGMENT_PROGRAM_ARB);
printf(" %d: %s\n", attr, name);
inputs &= ~(1 << attr);
}
}
/**
* Return ARB_v/f_prog-style output attrib string.
*/
static const char *
arb_output_attrib_string(GLint index, GLenum progType)
{
/*
* These strings should match the VERT_RESULT_x and FRAG_RESULT_x tokens.
*/
static const char *const vertResults[] = {
"result.position",
"result.color.primary",
"result.color.secondary",
"result.fogcoord",
"result.texcoord[0]",
"result.texcoord[1]",
"result.texcoord[2]",
"result.texcoord[3]",
"result.texcoord[4]",
"result.texcoord[5]",
"result.texcoord[6]",
"result.texcoord[7]",
"result.pointsize", /* VERT_RESULT_PSIZ */
"result.(thirteen)", /* VERT_RESULT_BFC0 */
"result.(fourteen)", /* VERT_RESULT_BFC1 */
"result.(fifteen)", /* VERT_RESULT_EDGE */
"result.(sixteen)", /* VERT_RESULT_CLIP_VERTEX */
"result.(seventeen)", /* VERT_RESULT_CLIP_D
prog_print.rar_style
版权申诉
191 浏览量
2022-09-19
22:10:41
上传
评论
收藏 8KB RAR 举报
weixin_42651887
- 粉丝: 81
- 资源: 1万+
最新资源
- 一个简单的示例代码,演示了如何进行基本的文件读写操作,包括打开文件、读写数据以及关闭文件
- linuxKernellinuxKernellinuxKernel
- Screenshot_20240612_075104_net.csdn.csdnplus.jpg
- Python环境搭建.md
- KnifeREC 推荐系统,使用lda,lightfm,deepctr等主流推荐模型KnifeREC-master.zip
- python,python-networking-flow.rar
- html5 admin模板自适应模板
- Gitlab+Jenkins+Maven+Codedeploy部署文档
- 第三章-2NumPy-1.ipynb
- 微信小程序期末大作业-点奶茶微信小程序源码+数据库(高分项目)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈