HIP Texture Support
Этот коммит содержится в:
@@ -25,20 +25,220 @@ THE SOFTWARE.
|
||||
|
||||
enum hipChannelFormatKind
|
||||
{
|
||||
hipChannelFormatKindSigned = 0,
|
||||
hipChannelFormatKindUnsigned = 1,
|
||||
hipChannelFormatKindFloat = 2,
|
||||
hipChannelFormatKindNone = 3
|
||||
hipChannelFormatKindSigned = 0,
|
||||
hipChannelFormatKindUnsigned = 1,
|
||||
hipChannelFormatKindFloat = 2,
|
||||
hipChannelFormatKindNone = 3
|
||||
};
|
||||
|
||||
struct hipChannelFormatDesc
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int w;
|
||||
enum hipChannelFormatKind f;
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int w;
|
||||
enum hipChannelFormatKind f;
|
||||
};
|
||||
|
||||
struct hipArray {
|
||||
void* data; //FIXME: generalize this
|
||||
struct hipChannelFormatDesc desc;
|
||||
unsigned int type;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int depth;
|
||||
};
|
||||
|
||||
typedef struct hipArray* hipArray_t;
|
||||
|
||||
typedef const struct hipArray* hipArray_const_t;
|
||||
|
||||
// TODO: It needs to be modified since it was just copied from hipArray.
|
||||
struct hipMipmappedArray {
|
||||
void* data; //FIXME: generalize this
|
||||
struct hipChannelFormatDesc desc;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int depth;
|
||||
};
|
||||
|
||||
typedef struct hipMipmappedArray *hipMipmappedArray_t;
|
||||
|
||||
typedef const struct hipMipmappedArray *hipMipmappedArray_const_t;
|
||||
|
||||
/**
|
||||
* hip resource types
|
||||
*/
|
||||
enum hipResourceType
|
||||
{
|
||||
hipResourceTypeArray = 0x00,
|
||||
hipResourceTypeMipmappedArray = 0x01,
|
||||
hipResourceTypeLinear = 0x02,
|
||||
hipResourceTypePitch2D = 0x03
|
||||
};
|
||||
|
||||
/**
|
||||
* hip texture resource view formats
|
||||
*/
|
||||
enum hipResourceViewFormat
|
||||
{
|
||||
hipResViewFormatNone = 0x00,
|
||||
hipResViewFormatUnsignedChar1 = 0x01,
|
||||
hipResViewFormatUnsignedChar2 = 0x02,
|
||||
hipResViewFormatUnsignedChar4 = 0x03,
|
||||
hipResViewFormatSignedChar1 = 0x04,
|
||||
hipResViewFormatSignedChar2 = 0x05,
|
||||
hipResViewFormatSignedChar4 = 0x06,
|
||||
hipResViewFormatUnsignedShort1 = 0x07,
|
||||
hipResViewFormatUnsignedShort2 = 0x08,
|
||||
hipResViewFormatUnsignedShort4 = 0x09,
|
||||
hipResViewFormatSignedShort1 = 0x0a,
|
||||
hipResViewFormatSignedShort2 = 0x0b,
|
||||
hipResViewFormatSignedShort4 = 0x0c,
|
||||
hipResViewFormatUnsignedInt1 = 0x0d,
|
||||
hipResViewFormatUnsignedInt2 = 0x0e,
|
||||
hipResViewFormatUnsignedInt4 = 0x0f,
|
||||
hipResViewFormatSignedInt1 = 0x10,
|
||||
hipResViewFormatSignedInt2 = 0x11,
|
||||
hipResViewFormatSignedInt4 = 0x12,
|
||||
hipResViewFormatHalf1 = 0x13,
|
||||
hipResViewFormatHalf2 = 0x14,
|
||||
hipResViewFormatHalf4 = 0x15,
|
||||
hipResViewFormatFloat1 = 0x16,
|
||||
hipResViewFormatFloat2 = 0x17,
|
||||
hipResViewFormatFloat4 = 0x18,
|
||||
hipResViewFormatUnsignedBlockCompressed1 = 0x19,
|
||||
hipResViewFormatUnsignedBlockCompressed2 = 0x1a,
|
||||
hipResViewFormatUnsignedBlockCompressed3 = 0x1b,
|
||||
hipResViewFormatUnsignedBlockCompressed4 = 0x1c,
|
||||
hipResViewFormatSignedBlockCompressed4 = 0x1d,
|
||||
hipResViewFormatUnsignedBlockCompressed5 = 0x1e,
|
||||
hipResViewFormatSignedBlockCompressed5 = 0x1f,
|
||||
hipResViewFormatUnsignedBlockCompressed6H = 0x20,
|
||||
hipResViewFormatSignedBlockCompressed6H = 0x21,
|
||||
hipResViewFormatUnsignedBlockCompressed7 = 0x22
|
||||
};
|
||||
|
||||
/**
|
||||
* HIP resource descriptor
|
||||
*/
|
||||
struct hipResourceDesc {
|
||||
enum hipResourceType resType;
|
||||
|
||||
union {
|
||||
struct {
|
||||
hipArray_t array;
|
||||
} array;
|
||||
struct {
|
||||
hipMipmappedArray_t mipmap;
|
||||
} mipmap;
|
||||
struct {
|
||||
void *devPtr;
|
||||
struct hipChannelFormatDesc desc;
|
||||
size_t sizeInBytes;
|
||||
} linear;
|
||||
struct {
|
||||
void *devPtr;
|
||||
struct hipChannelFormatDesc desc;
|
||||
size_t width;
|
||||
size_t height;
|
||||
size_t pitchInBytes;
|
||||
} pitch2D;
|
||||
} res;
|
||||
};
|
||||
|
||||
/**
|
||||
* hip resource view descriptor
|
||||
*/
|
||||
struct hipResourceViewDesc
|
||||
{
|
||||
enum hipResourceViewFormat format;
|
||||
size_t width;
|
||||
size_t height;
|
||||
size_t depth;
|
||||
unsigned int firstMipmapLevel;
|
||||
unsigned int lastMipmapLevel;
|
||||
unsigned int firstLayer;
|
||||
unsigned int lastLayer;
|
||||
};
|
||||
|
||||
/**
|
||||
* Memory copy types
|
||||
*
|
||||
*/
|
||||
typedef enum hipMemcpyKind {
|
||||
hipMemcpyHostToHost = 0, ///< Host-to-Host Copy
|
||||
hipMemcpyHostToDevice = 1, ///< Host-to-Device Copy
|
||||
hipMemcpyDeviceToHost = 2, ///< Device-to-Host Copy
|
||||
hipMemcpyDeviceToDevice =3, ///< Device-to-Device Copy
|
||||
hipMemcpyDefault = 4 ///< Runtime will automatically determine copy-kind based on virtual addresses.
|
||||
} hipMemcpyKind;
|
||||
|
||||
struct hipPitchedPtr
|
||||
{
|
||||
void *ptr;
|
||||
size_t pitch;
|
||||
size_t xsize;
|
||||
size_t ysize;
|
||||
};
|
||||
|
||||
struct hipExtent {
|
||||
size_t width; // Width in elements when referring to array memory, in bytes when referring to linear memory
|
||||
size_t height;
|
||||
size_t depth;
|
||||
};
|
||||
|
||||
struct hipPos {
|
||||
size_t x;
|
||||
size_t y;
|
||||
size_t z;
|
||||
};
|
||||
|
||||
struct hipMemcpy3DParms {
|
||||
hipArray_t srcArray;
|
||||
struct hipPos srcPos;
|
||||
struct hipPitchedPtr srcPtr;
|
||||
|
||||
hipArray_t dstArray;
|
||||
struct hipPos dstPos;
|
||||
struct hipPitchedPtr dstPtr;
|
||||
|
||||
struct hipExtent extent;
|
||||
enum hipMemcpyKind kind;
|
||||
};
|
||||
|
||||
static __inline__ struct hipPitchedPtr make_hipPitchedPtr(void *d, size_t p, size_t xsz, size_t ysz)
|
||||
{
|
||||
struct hipPitchedPtr s;
|
||||
|
||||
s.ptr = d;
|
||||
s.pitch = p;
|
||||
s.xsize = xsz;
|
||||
s.ysize = ysz;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static __inline__ struct hipPos make_hipPos(size_t x, size_t y, size_t z)
|
||||
{
|
||||
struct hipPos p;
|
||||
|
||||
p.x = x;
|
||||
p.y = y;
|
||||
p.z = z;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static __inline__ struct hipExtent make_hipExtent(size_t w, size_t h, size_t d)
|
||||
{
|
||||
struct hipExtent e;
|
||||
|
||||
e.width = w;
|
||||
e.height = h;
|
||||
e.depth = d;
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -81,12 +81,12 @@ namespace hip_impl
|
||||
extern int HIP_TRACE_API;
|
||||
|
||||
#ifdef __cplusplus
|
||||
//#include <hip/hcc_detail/hip_texture.h>
|
||||
#include <hip/hcc_detail/hip_ldg.h>
|
||||
#endif
|
||||
#include <hip/hcc_detail/host_defines.h>
|
||||
#include <hip/hcc_detail/math_functions.h>
|
||||
#include <hip/hcc_detail/device_functions.h>
|
||||
#include <hip/hcc_detail/texture_functions.h>
|
||||
|
||||
// TODO-HCC remove old definitions ; ~1602 hcc supports __HCC_ACCELERATOR__ define.
|
||||
#if defined (__KALMAR_ACCELERATOR__) && !defined (__HCC_ACCELERATOR__)
|
||||
|
||||
@@ -37,7 +37,8 @@ THE SOFTWARE.
|
||||
|
||||
#include <hip/hcc_detail/host_defines.h>
|
||||
#include <hip/hip_runtime_api.h>
|
||||
#include <hip/hip_texture.h>
|
||||
#include <hip/hcc_detail/driver_types.h>
|
||||
#include <hip/hcc_detail/hip_texture_types.h>
|
||||
|
||||
#if defined (__HCC__) && (__hcc_workweek__ < 16155)
|
||||
#error("This version of HIP requires a newer version of HCC.");
|
||||
@@ -136,6 +137,11 @@ enum hipLimit_t
|
||||
#define hipDeviceMapHost 0x8
|
||||
#define hipDeviceLmemResizeToMax 0x16
|
||||
|
||||
#define hipArrayDefault 0x00 ///< Default HIP array allocation flag
|
||||
#define hipArrayLayered 0x01
|
||||
#define hipArraySurfaceLoadStore 0x02
|
||||
#define hipArrayCubemap 0x04
|
||||
#define hipArrayTextureGather 0x08
|
||||
|
||||
/*
|
||||
* @brief hipJitOption
|
||||
@@ -200,27 +206,6 @@ typedef struct dim3 {
|
||||
} dim3;
|
||||
|
||||
|
||||
/**
|
||||
* Memory copy types
|
||||
*
|
||||
*/
|
||||
typedef enum hipMemcpyKind {
|
||||
hipMemcpyHostToHost = 0 ///< Host-to-Host Copy
|
||||
,hipMemcpyHostToDevice = 1 ///< Host-to-Device Copy
|
||||
,hipMemcpyDeviceToHost = 2 ///< Device-to-Host Copy
|
||||
,hipMemcpyDeviceToDevice =3 ///< Device-to-Device Copy
|
||||
,hipMemcpyDefault = 4, ///< Runtime will automatically determine copy-kind based on virtual addresses.
|
||||
} hipMemcpyKind;
|
||||
|
||||
typedef struct {
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
enum hipChannelFormatKind f;
|
||||
void* data; //FIXME: generalize this
|
||||
} hipArray;
|
||||
|
||||
|
||||
|
||||
// Doxygen end group GlobalDefs
|
||||
/** @} */
|
||||
|
||||
@@ -1287,6 +1272,19 @@ hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t s
|
||||
hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Fills the memory area pointed to by dst with the constant value.
|
||||
*
|
||||
* @param[out] dst Pointer to device memory
|
||||
* @param[in] pitch - data size in bytes
|
||||
* @param[in] value - constant value to be set
|
||||
* @param[in] width
|
||||
* @param[in] height
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree
|
||||
*/
|
||||
|
||||
hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t height);
|
||||
|
||||
/**
|
||||
* @brief Query memory info.
|
||||
* Return snapshot of free memory, and total allocatable memory on the device.
|
||||
@@ -1315,7 +1313,7 @@ hipError_t hipMemPtrGetInfo(void *ptr, size_t *size);
|
||||
*/
|
||||
#if __cplusplus
|
||||
hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc,
|
||||
size_t width, size_t height = 0, unsigned int flags = 0);
|
||||
size_t width, size_t height = 0, unsigned int flags = hipArrayDefault);
|
||||
#else
|
||||
hipError_t hipMallocArray(hipArray** array, const struct hipChannelFormatDesc* desc,
|
||||
size_t width, size_t height, unsigned int flags);
|
||||
@@ -1330,6 +1328,22 @@ hipError_t hipMallocArray(hipArray** array, const struct hipChannelFormatDesc* d
|
||||
*/
|
||||
hipError_t hipFreeArray(hipArray* array);
|
||||
|
||||
/**
|
||||
* @brief Allocate an array on the device.
|
||||
*
|
||||
* @param[out] array Pointer to allocated array in device memory
|
||||
* @param[in] desc Requested channel format
|
||||
* @param[in] extent Requested array allocation width, height and depth
|
||||
* @param[in] flags Requested properties of allocated array
|
||||
* @return #hipSuccess, #hipErrorMemoryAllocation
|
||||
*
|
||||
* @see hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree
|
||||
*/
|
||||
|
||||
hipError_t hipMalloc3DArray(hipArray_t *array,
|
||||
const struct hipChannelFormatDesc* desc,
|
||||
struct hipExtent extent,
|
||||
unsigned int flags);
|
||||
/**
|
||||
* @brief Copies data between host and device.
|
||||
*
|
||||
@@ -1402,6 +1416,7 @@ hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset,
|
||||
const void* src, size_t count, hipMemcpyKind kind);
|
||||
|
||||
|
||||
hipError_t hipMemcpy3D(const struct hipMemcpy3DParms *p);
|
||||
|
||||
// doxygen end Memory
|
||||
/**
|
||||
@@ -2150,6 +2165,24 @@ hipError_t hipIpcCloseMemHandle(void *devPtr);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
hipError_t hipBindTexture(size_t* offset,
|
||||
textureReference* tex,
|
||||
const void* devPtr,
|
||||
const hipChannelFormatDesc* desc,
|
||||
size_t size = UINT_MAX);
|
||||
|
||||
hipError_t ihipBindTextureImpl(int dim,
|
||||
enum hipTextureReadMode readMode,
|
||||
size_t *offset,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
size_t size,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject);
|
||||
|
||||
/*
|
||||
* @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex.
|
||||
*
|
||||
@@ -2164,15 +2197,15 @@ hipError_t hipIpcCloseMemHandle(void *devPtr);
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
|
||||
**/
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTexture(size_t *offset,
|
||||
struct texture<T, dim, readMode> &tex,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc *desc,
|
||||
size_t size=UINT_MAX)
|
||||
hipError_t hipBindTexture(size_t *offset,
|
||||
struct texture<T, dim, readMode>& tex,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
size_t size = UINT_MAX)
|
||||
{
|
||||
tex._dataPtr = static_cast<const T*>(devPtr);
|
||||
|
||||
return hipSuccess;
|
||||
return ihipBindTextureImpl(dim, readMode, offset, devPtr, desc, size,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2188,20 +2221,115 @@ hipError_t hipBindTexture(size_t *offset,
|
||||
* @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
|
||||
**/
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTexture(size_t *offset,
|
||||
struct texture<T, dim, readMode> &tex,
|
||||
const void *devPtr,
|
||||
size_t size=UINT_MAX)
|
||||
hipError_t hipBindTexture(size_t *offset,
|
||||
struct texture<T, dim, readMode>& tex,
|
||||
const void *devPtr,
|
||||
size_t size = UINT_MAX)
|
||||
{
|
||||
return hipBindTexture(offset, tex, devPtr, &tex.channelDesc, size);
|
||||
return ihipBindTextureImpl(dim, readMode, offset, devPtr, tex.channelDesc, size,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
}
|
||||
|
||||
// C API
|
||||
hipError_t hipBindTexture2D(size_t* offset,
|
||||
textureReference* tex,
|
||||
const void* devPtr,
|
||||
const hipChannelFormatDesc* desc,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t pitch);
|
||||
|
||||
hipError_t ihipBindTexture2DImpl(int dim,
|
||||
enum hipTextureReadMode readMode,
|
||||
size_t *offset,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
size_t width,
|
||||
size_t height,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject);
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTexture2D(size_t *offset,
|
||||
struct texture<T, dim, readMode>& tex,
|
||||
const void *devPtr,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t pitch)
|
||||
{
|
||||
return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, tex.channelDesc, width, height,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
}
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToArray(struct texture<T, dim, readMode> &tex, hipArray* array) {
|
||||
tex.width = array->width;
|
||||
tex.height = array->height;
|
||||
tex._dataPtr = static_cast<const T*>(array->data);
|
||||
return hipSuccess;
|
||||
hipError_t hipBindTexture2D(size_t *offset,
|
||||
struct texture<T, dim, readMode>& tex,
|
||||
const void *devPtr,
|
||||
const struct hipChannelFormatDesc &desc,
|
||||
size_t width,
|
||||
size_t height,
|
||||
size_t pitch)
|
||||
{
|
||||
return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, desc, width, height,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
}
|
||||
|
||||
//C API
|
||||
hipError_t hipBindTextureToArray(textureReference* tex,
|
||||
hipArray_const_t array,
|
||||
const hipChannelFormatDesc* desc);
|
||||
|
||||
hipError_t ihipBindTextureToArrayImpl(int dim,
|
||||
enum hipTextureReadMode readMode,
|
||||
hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc& desc,
|
||||
enum hipTextureAddressMode addressMode,
|
||||
enum hipTextureFilterMode filterMode,
|
||||
int normalizedCoords,
|
||||
hipTextureObject_t& textureObject);
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToArray(struct texture<T, dim, readMode>& tex,
|
||||
hipArray_const_t array)
|
||||
{
|
||||
return ihipBindTextureToArrayImpl(dim, readMode, array, tex.channelDesc,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
}
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToArray(struct texture<T, dim, readMode>& tex,
|
||||
hipArray_const_t array,
|
||||
const struct hipChannelFormatDesc& desc)
|
||||
{
|
||||
return ihipBindTextureToArrayImpl(dim, readMode, array, desc,
|
||||
tex.addressMode[0], tex.filterMode, tex.normalized,
|
||||
tex.textureObject);
|
||||
}
|
||||
|
||||
//C API
|
||||
hipError_t hipBindTextureToMipmappedArray(const textureReference* tex,
|
||||
hipMipmappedArray_const_t mipmappedArray,
|
||||
const hipChannelFormatDesc* desc);
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToMipmappedArray(const texture<T, dim, readMode>& tex,
|
||||
hipMipmappedArray_const_t mipmappedArray)
|
||||
{
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipBindTextureToMipmappedArray(const texture<T, dim, readMode>& tex,
|
||||
hipMipmappedArray_const_t mipmappedArray,
|
||||
const hipChannelFormatDesc& desc)
|
||||
{
|
||||
return hipSuccess;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2211,15 +2339,30 @@ hipError_t hipBindTextureToArray(struct texture<T, dim, readMode> &tex, hipArray
|
||||
*
|
||||
* @return #hipSuccess
|
||||
**/
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipUnbindTexture(struct texture<T, dim, readMode> &tex)
|
||||
{
|
||||
tex._dataPtr = NULL;
|
||||
hipError_t hipUnbindTexture(const textureReference* tex);
|
||||
|
||||
return hipSuccess;
|
||||
extern hipError_t ihipUnbindTextureImpl(const hipTextureObject_t& textureObject);
|
||||
|
||||
template <class T, int dim, enum hipTextureReadMode readMode>
|
||||
hipError_t hipUnbindTexture(struct texture<T, dim, readMode> &tex)
|
||||
{
|
||||
return ihipUnbindTextureImpl(tex.textureObject);
|
||||
}
|
||||
|
||||
hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array);
|
||||
hipError_t hipGetTextureAlignmentOffset (size_t* offset, const textureReference* texref);
|
||||
hipError_t hipGetTextureReference(const textureReference** texref, const void* symbol);
|
||||
|
||||
hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject,
|
||||
const hipResourceDesc* pResDesc,
|
||||
const hipTextureDesc* pTexDesc,
|
||||
const hipResourceViewDesc* pResViewDesc);
|
||||
|
||||
hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject);
|
||||
|
||||
hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc, hipTextureObject_t textureObject);
|
||||
hipError_t hipGetTextureObjectResourceViewDesc(hipResourceViewDesc* pResViewDesc, hipTextureObject_t textureObject);
|
||||
hipError_t hipGetTextureObjectTextureDesc(hipTextureDesc* pTexDesc, hipTextureObject_t textureObject);
|
||||
|
||||
// doxygen end Texture
|
||||
/**
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, 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 THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
//#pragma once
|
||||
|
||||
#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_H
|
||||
#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_H
|
||||
|
||||
/**
|
||||
* @file hcc_detail/hip_texture.h
|
||||
* @brief HIP C++ Texture API for hcc compiler
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <hip/hcc_detail/driver_types.h>
|
||||
#include <hip/hcc_detail/channel_descriptor.h>
|
||||
#include <hip/hcc_detail/texture_types.h>
|
||||
//#include <hip/hcc_detail/hip_runtime.h>
|
||||
|
||||
//----
|
||||
//Texture - TODO - likely need to move this to a separate file only included with kernel compilation.
|
||||
#define hipTextureType1D 1
|
||||
|
||||
#if __cplusplus
|
||||
template <class T, int texType=hipTextureType1D, hipTextureReadMode readMode=hipReadModeElementType>
|
||||
struct texture : public textureReference {
|
||||
|
||||
const T * _dataPtr; // pointer to underlying data.
|
||||
|
||||
//texture() : filterMode(hipFilterModePoint), normalized(false), _dataPtr(NULL) {};
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#define tex1Dfetch(_tex, _addr) (_tex._dataPtr[_addr])
|
||||
|
||||
#define tex2D(_tex, _dx, _dy) \
|
||||
_tex._dataPtr[(unsigned int)_dx + (unsigned int)_dy*(_tex.width)]
|
||||
|
||||
/**
|
||||
* @addtogroup API HIP API
|
||||
* @{
|
||||
*
|
||||
* Defines the HIP API. See the individual sections for more information.
|
||||
*/
|
||||
|
||||
// These are C++ APIs - maybe belong in separate file.
|
||||
/**
|
||||
*-------------------------------------------------------------------------------------------------
|
||||
*-------------------------------------------------------------------------------------------------
|
||||
* @defgroup Texture Texture Reference Management
|
||||
* @{
|
||||
*
|
||||
*
|
||||
* @warning The HIP texture API implements a small subset of full texture API. Known limitations include:
|
||||
* - Only point sampling is supported.
|
||||
* - Only C++ APIs are provided.
|
||||
* - Many APIs and modes are not implemented.
|
||||
*
|
||||
* The HIP texture support is intended to allow use of texture cache on hardware where this is beneficial.
|
||||
*
|
||||
* The following CUDA APIs are not currently supported:
|
||||
* - cudaBindTexture2D
|
||||
* - cudaBindTextureToArray
|
||||
* - cudaBindTextureToMipmappedArray
|
||||
* - cudaGetChannelDesc
|
||||
* - cudaGetTextureReference
|
||||
*
|
||||
*/
|
||||
|
||||
// C API:
|
||||
#if 0
|
||||
hipChannelFormatDesc hipBindTexture(size_t *offset, struct textureReference *tex, const void *devPtr, const struct hipChannelFormatDesc *desc, size_t size=UINT_MAX)
|
||||
{
|
||||
tex->_dataPtr = devPtr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// End doxygen API:
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
Copyright (c) 2015-2016 Advanced Micro Devices, 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 THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS 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 hcc_detail/hip_texture_types.h
|
||||
* @brief Defines the different newt vector types for HIP runtime.
|
||||
*/
|
||||
|
||||
#ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_TYPES_H
|
||||
#define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_TYPES_H
|
||||
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#include <limits.h>
|
||||
//#include <hip/hcc_detail/driver_types.h>
|
||||
#include <hip/hcc_detail/channel_descriptor.h>
|
||||
#include <hip/hcc_detail/texture_types.h>
|
||||
|
||||
#if __cplusplus
|
||||
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
template<class T, int texType = hipTextureType1D, enum hipTextureReadMode mode = hipReadModeElementType>
|
||||
struct texture : public textureReference
|
||||
{
|
||||
texture(int norm = 0,
|
||||
enum hipTextureFilterMode fMode = hipFilterModePoint,
|
||||
enum hipTextureAddressMode aMode = hipAddressModeClamp)
|
||||
{
|
||||
normalized = norm;
|
||||
filterMode = fMode;
|
||||
addressMode[0] = aMode;
|
||||
addressMode[1] = aMode;
|
||||
addressMode[2] = aMode;
|
||||
channelDesc = hipCreateChannelDesc<T>();
|
||||
sRGB = 0;
|
||||
}
|
||||
|
||||
texture(int norm,
|
||||
enum hipTextureFilterMode fMode,
|
||||
enum hipTextureAddressMode aMode,
|
||||
struct hipChannelFormatDesc desc)
|
||||
{
|
||||
normalized = norm;
|
||||
filterMode = fMode;
|
||||
addressMode[0] = aMode;
|
||||
addressMode[1] = aMode;
|
||||
addressMode[2] = aMode;
|
||||
channelDesc = desc;
|
||||
sRGB = 0;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* !HIP_INCLUDE_HIP_HCC_DETAIL_HIP_TEXTURE_TYPES_H */
|
||||
|
||||
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -26,20 +26,91 @@ THE SOFTWARE.
|
||||
|
||||
#include<hip/hcc_detail/driver_types.h>
|
||||
|
||||
enum hipTextureReadMode
|
||||
#define hipTextureType1D 0x01
|
||||
#define hipTextureType2D 0x02
|
||||
#define hipTextureType3D 0x03
|
||||
#define hipTextureTypeCubemap 0x0C
|
||||
#define hipTextureType1DLayered 0xF1
|
||||
#define hipTextureType2DLayered 0xF2
|
||||
#define hipTextureTypeCubemapLayered 0xFC
|
||||
|
||||
/**
|
||||
* Should be same as HSA_IMAGE_OBJECT_SIZE_DWORD/HSA_SAMPLER_OBJECT_SIZE_DWORD
|
||||
*/
|
||||
#define HIP_IMAGE_OBJECT_SIZE_DWORD 12
|
||||
#define HIP_SAMPLER_OBJECT_SIZE_DWORD 8
|
||||
#define HIP_SAMPLER_OBJECT_OFFSET_DWORD HIP_IMAGE_OBJECT_SIZE_DWORD
|
||||
#define HIP_TEXTURE_OBJECT_SIZE_DWORD (HIP_IMAGE_OBJECT_SIZE_DWORD + HIP_SAMPLER_OBJECT_SIZE_DWORD)
|
||||
|
||||
/**
|
||||
* An opaque value that represents a hip texture object
|
||||
*/
|
||||
typedef unsigned long long hipTextureObject_t;
|
||||
|
||||
/**
|
||||
* hip texture address modes
|
||||
*/
|
||||
enum hipTextureAddressMode
|
||||
{
|
||||
hipReadModeElementType = 0
|
||||
hipAddressModeWrap = 0,
|
||||
hipAddressModeClamp = 1,
|
||||
hipAddressModeMirror = 2,
|
||||
hipAddressModeBorder = 3
|
||||
};
|
||||
|
||||
/**
|
||||
* hip texture filter modes
|
||||
*/
|
||||
enum hipTextureFilterMode
|
||||
{
|
||||
hipFilterModePoint = 0
|
||||
hipFilterModePoint = 0,
|
||||
hipFilterModeLinear = 1
|
||||
};
|
||||
|
||||
struct textureReference {
|
||||
enum hipTextureFilterMode filterMode;
|
||||
unsigned normalized;
|
||||
struct hipChannelFormatDesc channelDesc;
|
||||
/**
|
||||
* hip texture read modes
|
||||
*/
|
||||
enum hipTextureReadMode
|
||||
{
|
||||
hipReadModeElementType = 0,
|
||||
hipReadModeNormalizedFloat = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* hip texture reference
|
||||
*/
|
||||
struct textureReference
|
||||
{
|
||||
int normalized;
|
||||
enum hipTextureFilterMode filterMode;
|
||||
enum hipTextureAddressMode addressMode[3]; //Texture address mode for up to 3 dimensions
|
||||
struct hipChannelFormatDesc channelDesc;
|
||||
int sRGB; // Perform sRGB->linear conversion during texture read
|
||||
unsigned int maxAnisotropy; // Limit to the anisotropy ratio
|
||||
enum hipTextureFilterMode mipmapFilterMode;
|
||||
float mipmapLevelBias;
|
||||
float minMipmapLevelClamp;
|
||||
float maxMipmapLevelClamp;
|
||||
|
||||
hipTextureObject_t textureObject;
|
||||
};
|
||||
|
||||
/**
|
||||
* hip texture descriptor
|
||||
*/
|
||||
struct hipTextureDesc
|
||||
{
|
||||
enum hipTextureAddressMode addressMode[3]; //Texture address mode for up to 3 dimensions
|
||||
enum hipTextureFilterMode filterMode;
|
||||
enum hipTextureReadMode readMode;
|
||||
int sRGB; // Perform sRGB->linear conversion during texture read
|
||||
float borderColor[4];
|
||||
int normalizedCoords;
|
||||
unsigned int maxAnisotropy;
|
||||
enum hipTextureFilterMode mipmapFilterMode;
|
||||
float mipmapLevelBias;
|
||||
float minMipmapLevelClamp;
|
||||
float maxMipmapLevelClamp;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
||||
Copyright (c) 2015-2017 Advanced Micro Devices, 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
|
||||
@@ -20,13 +20,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef HIP_INCLUDE_HIP_HIP_TEXTURE_H
|
||||
#define HIP_INCLUDE_HIP_HIP_TEXTURE_H
|
||||
|
||||
|
||||
#ifndef HIP_INCLUDE_HIP_HIP_TEXTURE_TYPES_H
|
||||
#define HIP_INCLUDE_HIP_HIP_TEXTURE_TYPES_H
|
||||
|
||||
#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__)
|
||||
#include <hip/hcc_detail/hip_texture.h>
|
||||
#include <hip/hcc_detail/hip_texture_types.h>
|
||||
#elif defined(__HIP_PLATFORM_NVCC__) && !defined (__HIP_PLATFORM_HCC__)
|
||||
#include <hip/nvcc_detail/hip_texture.h>
|
||||
#include <hip/nvcc_detail/hip_texture_types.h>
|
||||
#else
|
||||
#error("Must define exactly one of __HIP_PLATFORM_HCC__ or __HIP_PLATFORM_NVCC__");
|
||||
#endif
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2015 - present Advanced Micro Devices, 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 THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*/
|
||||
|
||||
#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_H
|
||||
#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_H
|
||||
|
||||
#include <texture_types.h>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_TYPES_H
|
||||
#define HIP_INCLUDE_HIP_NVCC_DETAIL_HIP_TEXTURE_TYPES_H
|
||||
|
||||
#include <texture_types.h>
|
||||
|
||||
#endif
|
||||
Ссылка в новой задаче
Block a user