P4 to Git Change 1136253 by gandryey@gera-w8 on 2015/03/31 12:51:46

ECR #304775 - Mipmaps support in OCL
	- Add changes for the sampler usage with mipmaped images

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_sampler.cpp#5 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#504 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#141 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp#113 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.h#46 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/sampler.hpp#7 edit
Tento commit je obsažen v:
foreman committed 2015-03-31 13:06:05 -04:00
1 rodič 9bff526ef0
revize 11dbd14b90
5 files changed
+79 -20

No files matched your search

+35 -5
Zobrazit soubor
@@ -1904,7 +1904,7 @@ Device::createSampler(const amd::Sampler& owner, device::Sampler** sampler) cons
*sampler = NULL;
if (settings().hsail_ || (settings().oclVersion_ >= OpenCL20)) {
Sampler* gpuSampler = new Sampler(*this);
if ((NULL == gpuSampler) || !gpuSampler->create(owner.state())) {
if ((NULL == gpuSampler) || !gpuSampler->create(owner)) {
delete gpuSampler;
return false;
}
@@ -2449,7 +2449,9 @@ Device::destroyScratchBuffers()
}
void
Device::fillHwSampler(uint32_t state, void* hwState, uint32_t hwStateSize) const
Device::fillHwSampler(
uint32_t state, void* hwState, uint32_t hwStateSize,
uint32_t mipFilter, float minLod, float maxLod) const
{
// All GSL sampler's parameters are in floats
uint32_t gslAddress = GSL_CLAMP_TO_BORDER;
@@ -2483,8 +2485,25 @@ Device::fillHwSampler(uint32_t state, void* hwState, uint32_t hwStateSize) const
gslMagFilter = GSL_MAG_LINEAR;
}
if (mipFilter == CL_FILTER_NEAREST) {
if (gslMinFilter == GSL_MIN_NEAREST) {
gslMinFilter = GSL_MIN_NEAREST_MIPMAP_NEAREST;
}
else {
gslMinFilter = GSL_MIN_LINEAR_MIPMAP_NEAREST;
}
}
else if (mipFilter == CL_FILTER_LINEAR) {
if (gslMinFilter == GSL_MIN_NEAREST) {
gslMinFilter = GSL_MIN_NEAREST_MIPMAP_LINEAR;
}
else {
gslMinFilter = GSL_MIN_LINEAR_MIPMAP_LINEAR;
}
}
fillSamplerHwState(unnorm, gslMinFilter, gslMagFilter,
gslAddress, hwState, hwStateSize);
gslAddress, minLod, maxLod, hwState, hwStateSize);
}
void*
@@ -2564,8 +2583,7 @@ Device::SrdManager::~SrdManager()
}
bool
Sampler::create(
uint32_t oclSamplerState)
Sampler::create(uint32_t oclSamplerState)
{
hwSrd_ = dev_.srds().allocSrdSlot(&hwState_);
if (0 == hwSrd_) {
@@ -2575,6 +2593,18 @@ Sampler::create(
return true;
}
bool
Sampler::create(const amd::Sampler& owner)
{
hwSrd_ = dev_.srds().allocSrdSlot(&hwState_);
if (0 == hwSrd_) {
return false;
}
dev_.fillHwSampler(owner.state(), hwState_, HsaSamplerObjectSize,
owner.mipFilter(), owner.minLod(), owner.maxLod());
return true;
}
Sampler::~Sampler()
{
dev_.srds().freeSrdSlot(hwSrd_);
+15 -3
Zobrazit soubor
@@ -140,6 +140,10 @@ class VirtualDevice;
class PrintfDbg;
class ThreadTrace;
#ifndef CL_FILTER_NONE
#define CL_FILTER_NONE 0x1142
#endif
class Sampler : public device::Sampler
{
public:
@@ -154,6 +158,11 @@ public:
uint32_t oclSamplerState //!< OCL sampler state
);
//! Creates a device sampler from the OCL sampler state
bool create(
const amd::Sampler& owner //!< AMD sampler object
);
const void* hwState() const { return hwState_; }
private:
@@ -518,9 +527,12 @@ public:
//! Set GSL sampler to the specified state
void fillHwSampler(
uint32_t state, //!< Sampler's OpenCL state
void* hwState, //!< Sampler's HW state
uint32_t hwStateSize //!< Size of sampler's HW state
uint32_t state, //!< Sampler's OpenCL state
void* hwState, //!< Sampler's HW state
uint32_t hwStateSize, //!< Size of sampler's HW state
uint32_t mipFilter = CL_FILTER_NONE, //!< Mip filter
float minLod = 0.f, //!< Min level of detail
float maxLod = CL_MAXFLOAT //!< Max level of detail
) const;
//! host memory alloc
+4 -1
Zobrazit soubor
@@ -1726,7 +1726,8 @@ CALGSLDevice::fillImageHwState(gslMemObject mem, void* hwState, uint32 hwStateSi
}
void
CALGSLDevice::fillSamplerHwState(bool unnorm, uint32 min, uint32 mag, uint32 addr, void* hwState, uint32 hwStateSize) const
CALGSLDevice::fillSamplerHwState(bool unnorm, uint32 min, uint32 mag, uint32 addr,
float minLod, float maxLod, void* hwState, uint32 hwStateSize) const
{
amd::ScopedLock k(gslDeviceOps());
m_textureSampler->setUnnormalizedMode(m_cs, unnorm);
@@ -1735,6 +1736,8 @@ CALGSLDevice::fillSamplerHwState(bool unnorm, uint32 min, uint32 mag, uint32 add
m_textureSampler->setWrap(m_cs, GSL_TEXTURE_WRAP_S, static_cast<gslTexParameterParamWrap>(addr));
m_textureSampler->setWrap(m_cs, GSL_TEXTURE_WRAP_T, static_cast<gslTexParameterParamWrap>(addr));
m_textureSampler->setWrap(m_cs, GSL_TEXTURE_WRAP_R, static_cast<gslTexParameterParamWrap>(addr));
m_textureSampler->setMinLOD(m_cs, static_cast<float32>(minLod));
m_textureSampler->setMaxLOD(m_cs, static_cast<float32>(maxLod));
m_textureSampler->getSamplerSrd(m_cs, hwState, hwStateSize);
}
+2 -1
Zobrazit soubor
@@ -126,7 +126,8 @@ public:
void fillImageHwState(gslMemObject mem, void* hwState, uint32 hwStateSize) const;
void fillSamplerHwState(bool unnorm, uint32 min, uint32 mag, uint32 addr, void* hwState, uint32 hwStateSize) const;
void fillSamplerHwState(bool unnorm, uint32 min, uint32 mag, uint32 addr,
float minLod, float maxLod, void* hwState, uint32 hwStateSize) const;
gslSamplerObject txSampler() const { return m_textureSampler; }