patched examples to work with uniform for nvptx. function calls with non-generic pointers fail. need fix
This commit is contained in:
@@ -51,8 +51,12 @@
|
|||||||
#endif // ISPC_IS_LINUX
|
#endif // ISPC_IS_LINUX
|
||||||
|
|
||||||
// Currently tile widths must be a multiple of SIMD width (i.e. 8 for ispc sse4x2)!
|
// Currently tile widths must be a multiple of SIMD width (i.e. 8 for ispc sse4x2)!
|
||||||
|
#ifndef MIN_TILE_WIDTH
|
||||||
#define MIN_TILE_WIDTH 16
|
#define MIN_TILE_WIDTH 16
|
||||||
|
#endif
|
||||||
|
#ifndef MIN_TILE_HEIGHT
|
||||||
#define MIN_TILE_HEIGHT 16
|
#define MIN_TILE_HEIGHT 16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define DYNAMIC_TREE_LEVELS 5
|
#define DYNAMIC_TREE_LEVELS 5
|
||||||
|
|||||||
@@ -33,6 +33,12 @@
|
|||||||
|
|
||||||
#include "deferred.h"
|
#include "deferred.h"
|
||||||
|
|
||||||
|
#ifdef __NVPTX__
|
||||||
|
#define uniform_t varying
|
||||||
|
#else
|
||||||
|
#define uniform_t uniform
|
||||||
|
#endif
|
||||||
|
|
||||||
struct InputDataArrays
|
struct InputDataArrays
|
||||||
{
|
{
|
||||||
float *zBuffer;
|
float *zBuffer;
|
||||||
@@ -166,19 +172,19 @@ IntersectLightsWithTileMinMax(
|
|||||||
uniform float gBufferScale_x = 0.5f * (float)gBufferWidth;
|
uniform float gBufferScale_x = 0.5f * (float)gBufferWidth;
|
||||||
uniform float gBufferScale_y = 0.5f * (float)gBufferHeight;
|
uniform float gBufferScale_y = 0.5f * (float)gBufferHeight;
|
||||||
|
|
||||||
uniform float frustumPlanes_xy[4] = {
|
uniform_t float frustumPlanes_xy[4] = {
|
||||||
-(cameraProj_11 * gBufferScale_x),
|
-(cameraProj_11 * gBufferScale_x),
|
||||||
(cameraProj_11 * gBufferScale_x),
|
(cameraProj_11 * gBufferScale_x),
|
||||||
(cameraProj_22 * gBufferScale_y),
|
(cameraProj_22 * gBufferScale_y),
|
||||||
-(cameraProj_22 * gBufferScale_y) };
|
-(cameraProj_22 * gBufferScale_y) };
|
||||||
uniform float frustumPlanes_z[4] = {
|
uniform_t float frustumPlanes_z[4] = {
|
||||||
tileEndX - gBufferScale_x,
|
tileEndX - gBufferScale_x,
|
||||||
-tileStartX + gBufferScale_x,
|
-tileStartX + gBufferScale_x,
|
||||||
tileEndY - gBufferScale_y,
|
tileEndY - gBufferScale_y,
|
||||||
-tileStartY + gBufferScale_y };
|
-tileStartY + gBufferScale_y };
|
||||||
|
|
||||||
for (uniform int i = 0; i < 4; ++i) {
|
for (uniform int i = 0; i < 4; ++i) {
|
||||||
uniform float norm = rsqrt(frustumPlanes_xy[i] * frustumPlanes_xy[i] +
|
uniform_t float norm = rsqrt(frustumPlanes_xy[i] * frustumPlanes_xy[i] +
|
||||||
frustumPlanes_z[i] * frustumPlanes_z[i]);
|
frustumPlanes_z[i] * frustumPlanes_z[i]);
|
||||||
frustumPlanes_xy[i] *= norm;
|
frustumPlanes_xy[i] *= norm;
|
||||||
frustumPlanes_z[i] *= norm;
|
frustumPlanes_z[i] *= norm;
|
||||||
@@ -621,13 +627,13 @@ SplitTileMinMax(
|
|||||||
uniform float gBufferScale_x = 0.5f * (float)gBufferWidth;
|
uniform float gBufferScale_x = 0.5f * (float)gBufferWidth;
|
||||||
uniform float gBufferScale_y = 0.5f * (float)gBufferHeight;
|
uniform float gBufferScale_y = 0.5f * (float)gBufferHeight;
|
||||||
|
|
||||||
uniform float frustumPlanes_xy[2] = { -(cameraProj_11 * gBufferScale_x),
|
uniform_t float frustumPlanes_xy[2] = { -(cameraProj_11 * gBufferScale_x),
|
||||||
(cameraProj_22 * gBufferScale_y) };
|
(cameraProj_22 * gBufferScale_y) };
|
||||||
uniform float frustumPlanes_z[2] = { tileMidX - gBufferScale_x,
|
uniform_t float frustumPlanes_z[2] = { tileMidX - gBufferScale_x,
|
||||||
tileMidY - gBufferScale_y };
|
tileMidY - gBufferScale_y };
|
||||||
|
|
||||||
// Normalize
|
// Normalize
|
||||||
uniform float norm[2] = { rsqrt(frustumPlanes_xy[0] * frustumPlanes_xy[0] +
|
uniform_t float norm[2] = { rsqrt(frustumPlanes_xy[0] * frustumPlanes_xy[0] +
|
||||||
frustumPlanes_z[0] * frustumPlanes_z[0]),
|
frustumPlanes_z[0] * frustumPlanes_z[0]),
|
||||||
rsqrt(frustumPlanes_xy[1] * frustumPlanes_xy[1] +
|
rsqrt(frustumPlanes_xy[1] * frustumPlanes_xy[1] +
|
||||||
frustumPlanes_z[1] * frustumPlanes_z[1]) };
|
frustumPlanes_z[1] * frustumPlanes_z[1]) };
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ volume_task(float density[], int _nVoxels[3],
|
|||||||
int width, int height, float image[]) {
|
int width, int height, float image[]) {
|
||||||
if (taskIndex0 >= taskCount0) return;
|
if (taskIndex0 >= taskCount0) return;
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
int nVoxels[3];
|
int nVoxels[3];
|
||||||
nVoxels[0] = _nVoxels[0];
|
nVoxels[0] = _nVoxels[0];
|
||||||
nVoxels[1] = _nVoxels[1];
|
nVoxels[1] = _nVoxels[1];
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ volume_task(uniform float density[], uniform int _nVoxels[3],
|
|||||||
{
|
{
|
||||||
if (taskIndex >= taskCount) return;
|
if (taskIndex >= taskCount) return;
|
||||||
|
|
||||||
#if 1
|
#if 0 /* cannot pass shared memory pointers to functions, need to find a way to solve this one :S */
|
||||||
uniform int nVoxels[3];
|
uniform int nVoxels[3];
|
||||||
nVoxels[0] = _nVoxels[0];
|
nVoxels[0] = _nVoxels[0];
|
||||||
nVoxels[1] = _nVoxels[1];
|
nVoxels[1] = _nVoxels[1];
|
||||||
|
|||||||
8
stmt.cpp
8
stmt.cpp
@@ -263,13 +263,14 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
g->target->getISA() == Target::NVPTX)
|
g->target->getISA() == Target::NVPTX)
|
||||||
{
|
{
|
||||||
/* deal with "const uniform" or "uniform" arrays for nvptx target */
|
/* deal with "const uniform" or "uniform" arrays for nvptx target */
|
||||||
|
if (!sym->type->IsConstType())
|
||||||
PerformanceWarning(sym->pos,
|
PerformanceWarning(sym->pos,
|
||||||
"\"uniform\" arrays might be slow with \"nvptx\" target. "
|
"\"uniform\" arrays might be slow with \"nvptx\" target. "
|
||||||
"Unless data sharing between program instances is required, use \"varying\" if possible.");
|
"Unless data sharing between program instances is required, use \"varying\" if possible.");
|
||||||
if (initExpr != NULL && !sym->type->IsConstType())
|
if (initExpr != NULL && !sym->type->IsConstType())
|
||||||
Error(initExpr->pos,
|
Error(initExpr->pos,
|
||||||
"It is not possible to initialize non-constant \"uniform\" array \"%s\" with \"nvptx\" target. "
|
"It is not possible to initialize non-constant \"uniform\" array \"%s\" with \"nvptx\" target. "
|
||||||
"Please use \"varying\" or \"const static uniform\".",
|
"Please use \"varying\", \"const static uniform\" or define initializer in the global scope.",
|
||||||
sym->name.c_str());
|
sym->name.c_str());
|
||||||
|
|
||||||
llvm::Constant *cinit = NULL;
|
llvm::Constant *cinit = NULL;
|
||||||
@@ -277,7 +278,11 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
int addressSpace;
|
int addressSpace;
|
||||||
if (sym->type->IsConstType())
|
if (sym->type->IsConstType())
|
||||||
{
|
{
|
||||||
|
#if 0 /* current, addressSpace = 4 generates a compilation fails as it can't be passed as a function arg:S */
|
||||||
addressSpace = 4; /* constant */
|
addressSpace = 4; /* constant */
|
||||||
|
#else
|
||||||
|
addressSpace = 0; /* use global for now */
|
||||||
|
#endif
|
||||||
if (initExpr != NULL) {
|
if (initExpr != NULL) {
|
||||||
if (PossiblyResolveFunctionOverloads(initExpr, sym->type) == false)
|
if (PossiblyResolveFunctionOverloads(initExpr, sym->type) == false)
|
||||||
continue;
|
continue;
|
||||||
@@ -309,6 +314,7 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* fails if pointer passed to function argument, need conversion beforehand */
|
||||||
addressSpace = 3; /* local */
|
addressSpace = 3; /* local */
|
||||||
const ArrayType *at = CastType<ArrayType>(sym->type);
|
const ArrayType *at = CastType<ArrayType>(sym->type);
|
||||||
const int nel = at->GetElementCount();
|
const int nel = at->GetElementCount();
|
||||||
|
|||||||
Reference in New Issue
Block a user