diff options
Diffstat (limited to 'src/cuda-sim')
| -rw-r--r-- | src/cuda-sim/instructions.cc | 28 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_sim.cc | 4 |
2 files changed, 31 insertions, 1 deletions
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc index 5decd2b..7cdf0de 100644 --- a/src/cuda-sim/instructions.cc +++ b/src/cuda-sim/instructions.cc @@ -2721,7 +2721,33 @@ void tex_impl( const ptx_instruction *pI, ptx_thread_info *thread ) switch (dimension) { case GEOM_MODIFIER_1D: - x = ptx_tex_regs[0].u64; + width = cuArray->width; + height = cuArray->height; + if (texref->normalized) { + x_f32 = ptx_tex_regs[0].f32; + if (texref->addressMode[0] == cudaAddressModeClamp) { + x_f32 = (x_f32 > 1.0)? 1.0 : x_f32; + x_f32 = (x_f32 < 0.0)? 0.0 : x_f32; + } else if (texref->addressMode[0] == cudaAddressModeWrap) { + x_f32 = x_f32 - floor(x_f32); + } + + if( texref->filterMode == cudaFilterModeLinear ) { + float xb = x_f32 * width - 0.5; + alpha = xb - floor(xb); + alpha = reduce_precision(alpha,9); + beta = 0.0; + + x = (int)floor(xb); + y = 0; + } else { + x = (int) floor(x_f32 * width); + y = 0; + } + } else { + x = ptx_tex_regs[0].u64; + } + width *= (cuArray->desc.w+cuArray->desc.x+cuArray->desc.y+cuArray->desc.z)/8; x *= (cuArray->desc.w+cuArray->desc.x+cuArray->desc.y+cuArray->desc.z)/8; tex_array_index = tex_array_base + x; diff --git a/src/cuda-sim/ptx_sim.cc b/src/cuda-sim/ptx_sim.cc index a1a77fd..6a62783 100644 --- a/src/cuda-sim/ptx_sim.cc +++ b/src/cuda-sim/ptx_sim.cc @@ -316,6 +316,10 @@ static void print_reg( std::string name, ptx_reg_t value ) return; } const type_info *t = sym->type(); + if( t == NULL ) { + printf("<unknown type> 0x%llx\n", (unsigned long long ) value.u64 ); + return; + } type_info_key ti = t->get_key(); switch ( ti.scalar_type() ) { |
