/*
* Multi2Sim
* Copyright (C) 2012 Rafael Ubal ([email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <assert.h>
#include <arch/x86/emu/context.h>
#include <arch/x86/emu/regs.h>
#include <arch/southern-islands/emu/ndrange.h>
#include <arch/southern-islands/emu/opengl-bin-file.h>
#include <driver/glut/frame-buffer.h>
#include <lib/mhandle/mhandle.h>
#include <lib/util/debug.h>
#include <lib/util/list.h>
#include <lib/util/misc.h>
#include <lib/util/string.h>
#include <mem-system/memory.h>
#include "buffers.h"
#include "buffer-obj.h"
#include "context.h"
#include "light.h"
#include "material.h"
#include "matrix.h"
#include "matrix-stack.h"
#include "opengl.h"
#include "program.h"
#include "rasterizer.h"
#include "shader.h"
#include "transform-feedback.h"
#include "vertex.h"
#include "vertex-array.h"
#include "viewport.h"
/* Debug */
int opengl_debug_category;
/* Error messages */
static char *opengl_err_not_impl =
"\tThe OpenGL interface is implemented in library 'm2s-opengl.so' as a set of\n"
"\tsystem calls, intercepted by Multi2Sim and emulated in 'opengl.c'.\n"
"\tHowever, only a subset of this interface is currently implemented in the simulator.\n"
"\tTo request the implementation of a specific OpenGL call, please email\n"
"\t'[email protected]'.\n";
static char *opengl_version_code =
"\tAn invalid function code was generated by your application in a OpenGL system\n"
"\tcall. Probably, this means that your application is using an incompatible\n"
"\tversion of the Multi2Sim OpenGL runtime library ('libm2s-opengl'). Please\n"
"\trecompile your application and try again.\n";
/* List of OPENGL runtime calls */
enum opengl_call_t
{
opengl_call_invalid = 0,
#define OPENGL_DEFINE_CALL(name, code) opengl_call_##name = code,
#include "opengl.dat"
#undef OPENGL_DEFINE_CALL
opengl_call_count
};
/* List of OPENGL runtime call names */
char *opengl_call_name[opengl_call_count + 1] =
{
NULL,
#define OPENGL_DEFINE_CALL(name, code) #name,
#include "opengl.dat"
#undef OPENGL_DEFINE_CALL
NULL
};
/* Forward declarations of OPENGL runtime functions */
#define OPENGL_DEFINE_CALL(name, code) \
static int opengl_func_##name(struct x86_ctx_t *ctx);
#include "opengl.dat"
#undef OPENGL_DEFINE_CALL
/* List of OPENGL runtime functions */
typedef int (*opengl_func_t)(struct x86_ctx_t *ctx);
static opengl_func_t opengl_func_table[opengl_call_count + 1] =
{
NULL,
#define OPENGL_DEFINE_CALL(name, code) opengl_func_##name,
#include "opengl.dat"
#undef OPENGL_DEFINE_CALL
NULL
};
#define __NOT_IMPL__ fatal("%s: not implemented.\n%s", \
__FUNCTION__, opengl_err_not_impl);
/*
* OpenGL global variables
*/
/* OpenGL Context */
struct opengl_context_t *opengl_ctx;
static void opengl_set_error(int error)
{
opengl_ctx->gl_error = error;
}
void opengl_init(void)
{
opengl_debug("Initializing OpenGL context\n");
opengl_ctx = opengl_context_create();
}
void opengl_done(void)
{
if (opengl_ctx != NULL)
opengl_context_free(opengl_ctx);
}
int opengl_abi_call(struct x86_ctx_t *ctx)
{
struct x86_regs_t *regs = ctx->regs;
/* Variables */
int code;
int ret;
/* Function code */
code = regs->ebx;
if (code <= opengl_call_invalid || code >= opengl_call_count)
fatal("%s: invalid OpenGL function (code %d).\n%s",
__FUNCTION__, code, opengl_version_code);
/* Debug */
opengl_debug("OpenGL runtime call '%s' (code %d)\n",
opengl_call_name[code], code);
/* Call OPENGL function */
assert(opengl_func_table[code]);
ret = opengl_func_table[code](ctx);
/* Return value */
return ret;
}
/*
* OpenGL call #1 - glClearIndex
*
* glClearIndex -
*
* @return
* This function always returns 0
*/
static int opengl_func_glClearIndex(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #2 - glClearColor
*
* glClearColor - specify clear values for the color buffers
*
* @return
* The function always returns 0
*/
static int opengl_func_glClearColor(struct x86_ctx_t *ctx)
{
struct x86_regs_t *regs = ctx->regs;
struct mem_t *mem = ctx->mem;
GLfloat args[4];
GLfloat red;
GLfloat green;
GLfloat blue;
GLfloat alpha;
/* Read arguments */
mem_read(mem, regs->ecx, 4 * sizeof(GLfloat), args);
red = args[0];
green = args[1];
blue = args[2];
alpha = args[3];
/* Debug */
opengl_debug("OpenGL runtime call parameters: (%f, %f, %f, %f)\n", args[0], args[1], args[2], args[3]);
opengl_debug("\tClear color: RGBA = [%f, %f, %f, %f]\n", red, green, blue, alpha);
/* Set clear color */
/* Return */
return 0;
}
/*
* OpenGL call #3 - glClear
*
* glClear - clear buffers to present values
*
* @return
* The function always returns 0
*/
static int opengl_func_glClear(struct x86_ctx_t *ctx)
{
struct x86_regs_t *regs = ctx->regs;
struct mem_t *mem = ctx->mem;
unsigned int mask_ptr;
GLbitfield mask;
/* Read arguments */
mask_ptr = regs->ecx;
mem_read(mem, mask_ptr, sizeof(GLbitfield), &mask);
opengl_debug("\tmask_ptr=0x%x\n", mask_ptr);
opengl_debug("\tmask=0x%x\n", mask);
/* Clear frame buffers*/
opengl_frame_buffer_clear(opengl_ctx->draw_buffer, mask);
opengl_frame_buffer_clear(opengl_ctx->read_buffer, mask);
/* Return */
return 0;
}
/*
* OpenGL call #4 - glIndexMask
*
* glIndexMask -
*
* @return
* This function always returns 0
*/
static int opengl_func_glIndexMask(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #5 - glColorMask
*
* glColorMask -
*
* @return
* This function always returns 0
*/
static int opengl_func_glColorMask(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #6 - glAlphaFunc
*
* glAlphaFunc -
*
* @return
* This function always returns 0
*/
static int opengl_func_glAlphaFunc(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #7 - glBlendFunc
*
* glBlendFunc -
*
* @return
* This function always returns 0
*/
static int opengl_func_glBlendFunc(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #8 - glLogicOp
*
* glLogicOp -
*
* @return
* This function always returns 0
*/
static int opengl_func_glLogicOp(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #9 - glCullFace
*
* glCullFace -
*
* @return
* This function always returns 0
*/
static int opengl_func_glCullFace(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #10 - glFrontFace
*
* glFrontFace -
*
* @return
* This function always returns 0
*/
static int opengl_func_glFrontFace(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #11 - glPointSize
*
* glPointSize -
*
* @return
* This function always returns 0
*/
static int opengl_func_glPointSize(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #12 - glLineWidth
*
* glLineWidth -
*
* @return
* This function always returns 0
*/
static int opengl_func_glLineWidth(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #13 - glLineStipple
*
* glLineStipple -
*
* @return
* This function always returns 0
*/
static int opengl_func_glLineStipple(struct x86_ctx_t *ctx)
{
__NOT_IMPL__
return 0;
}
/*
* OpenGL call #14 - glPolygonMode
*
* glPolygonMode -
*
* @return
* This function always returns 0
*/
static int opengl_func_glPolygon
没有合适的资源?快使用搜索试试~ 我知道了~
multi2sim-4.1.tar.gz_multi2sim
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 191 浏览量
2022-09-20
20:56:03
上传
评论
收藏 6.36MB GZ 举报
温馨提示
共869个文件
c:337个
h:310个
am:62个
Multi2Sim CPU-GPU 仿真器, 4.1版本 基于Linux的版本。可以用GNU make编译。 可以设计自己的CPU或者CPU-GPU架构,然后仿真。
资源推荐
资源详情
资源评论
收起资源包目录
multi2sim-4.1.tar.gz_multi2sim (869个子文件)
configure.ac 15KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 1KB
Makefile.am 1KB
Makefile.am 774B
Makefile.am 642B
Makefile.am 609B
Makefile.am 562B
Makefile.am 561B
Makefile.am 551B
Makefile.am 543B
Makefile.am 499B
Makefile.am 496B
Makefile.am 469B
Makefile.am 432B
Makefile.am 366B
Makefile.am 361B
Makefile.am 350B
Makefile.am 349B
Makefile.am 330B
Makefile.am 319B
Makefile.am 319B
Makefile.am 318B
Makefile.am 315B
Makefile.am 290B
Makefile.am 290B
Makefile.am 290B
Makefile.am 288B
Makefile.am 286B
Makefile.am 284B
Makefile.am 281B
Makefile.am 259B
Makefile.am 256B
Makefile.am 230B
Makefile.am 188B
Makefile.am 188B
Makefile.am 180B
Makefile.am 164B
Makefile.am 136B
Makefile.am 123B
Makefile.am 119B
Makefile.am 115B
Makefile.am 105B
Makefile.am 105B
Makefile.am 105B
Makefile.am 104B
Makefile.am 100B
Makefile.am 91B
Makefile.am 87B
Makefile.am 84B
Makefile.am 84B
Makefile.am 75B
Makefile.am 71B
Makefile.am 38B
Makefile.am 35B
Makefile.am 34B
Makefile.am 34B
Makefile.am 34B
Makefile.am 34B
Makefile.am 34B
Makefile.am 24B
Makefile.am 23B
AUTHORS 4KB
opengl.c 576KB
api.c 245KB
api.c 219KB
machine.c 169KB
syscall.c 128KB
machine.c 95KB
nmoesi-protocol.c 85KB
opencl.c 76KB
machine.c 59KB
asm.c 58KB
parser.c 57KB
m2s.c 56KB
machine.c 53KB
machine-sse2.c 52KB
gpu.c 51KB
config.c 50KB
asm.c 50KB
gpu.c 50KB
lex.c 49KB
asm.c 46KB
si-kernel.c 46KB
machine-fp.c 44KB
cpu.c 40KB
bin-file.c 39KB
compute-unit.c 39KB
asm-dump.c 38KB
sm.c 35KB
syscall.c 35KB
api.c 35KB
isa.c 34KB
matrix.c 30KB
gpu.c 29KB
context.c 29KB
asm.c 29KB
bin-file.c 28KB
mod-widget.c 27KB
共 869 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
小贝德罗
- 粉丝: 70
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功