mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-19 18:45:43 +00:00
Created an execution object for Texture2D
abstracted out the execution object from the execution object factory and removed the device template from the factory.
This commit is contained in:
parent
7cb2421edf
commit
7eb3556491
@ -170,7 +170,7 @@ struct RenderBitmapFontExecutor
|
||||
|
||||
vtkm::worklet::DispatcherMapField<RenderBitmapFont, Device> dispatcher(Worklet);
|
||||
dispatcher.Invoke(
|
||||
ScreenCoords, TextureCoords, FontTexture.GetExecObject<Device>(), ColorBuffer, DepthBuffer);
|
||||
ScreenCoords, TextureCoords, FontTexture.GetExecObjectFactory(), ColorBuffer, DepthBuffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class Texture2D
|
||||
public:
|
||||
using TextureDataHandle = typename vtkm::cont::ArrayHandle<vtkm::UInt8>;
|
||||
using ColorType = vtkm::Vec<vtkm::Float32, NumComponents>;
|
||||
template <typename DeviceTag>
|
||||
|
||||
class Texture2DSampler;
|
||||
|
||||
#define UV_BOUNDS_CHECK(u, v, NoneType) \
|
||||
@ -95,46 +95,40 @@ public:
|
||||
VTKM_CONT
|
||||
void SetWrapMode(TextureWrapMode wrapMode) { this->WrapMode = wrapMode; }
|
||||
|
||||
template <typename DeviceTag>
|
||||
VTKM_CONT Texture2DSampler<DeviceTag> GetExecObject() const
|
||||
VTKM_CONT Texture2DSampler GetExecObjectFactory() const
|
||||
{
|
||||
return Texture2DSampler<DeviceTag>(Width, Height, Data, FilterMode, WrapMode);
|
||||
Texture2DSampler executionObjectFactory(Width, Height, Data, FilterMode, WrapMode);
|
||||
return executionObjectFactory;
|
||||
}
|
||||
|
||||
template <typename DeviceTag>
|
||||
class Texture2DSampler : public vtkm::cont::ExecutionObjectFactoryBase
|
||||
template <typename Device>
|
||||
class Texture2DSamplerExecutionObject
|
||||
{
|
||||
public:
|
||||
using TextureExecPortal =
|
||||
typename TextureDataHandle::template ExecutionTypes<DeviceTag>::PortalConst;
|
||||
typename TextureDataHandle::template ExecutionTypes<Device>::PortalConst;
|
||||
|
||||
VTKM_CONT
|
||||
Texture2DSampler()
|
||||
Texture2DSamplerExecutionObject()
|
||||
: Width(0)
|
||||
, Height(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Texture2DSampler(vtkm::Id width,
|
||||
vtkm::Id height,
|
||||
const TextureDataHandle& data,
|
||||
TextureFilterMode filterMode,
|
||||
TextureWrapMode wrapMode)
|
||||
Texture2DSamplerExecutionObject(vtkm::Id width,
|
||||
vtkm::Id height,
|
||||
const TextureDataHandle& data,
|
||||
TextureFilterMode filterMode,
|
||||
TextureWrapMode wrapMode)
|
||||
: Width(width)
|
||||
, Height(height)
|
||||
, Data(data.PrepareForInput(DeviceTag()))
|
||||
, Data(data.PrepareForInput(Device()))
|
||||
, FilterMode(filterMode)
|
||||
, WrapMode(wrapMode)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT Texture2DSampler<Device> PrepareForExecution(Device) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
inline ColorType GetColor(vtkm::Float32 u, vtkm::Float32 v) const
|
||||
{
|
||||
@ -216,6 +210,55 @@ public:
|
||||
TextureExecPortal Data;
|
||||
TextureFilterMode FilterMode;
|
||||
TextureWrapMode WrapMode;
|
||||
};
|
||||
|
||||
class Texture2DSampler : public vtkm::cont::ExecutionObjectFactoryBase
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
Texture2DSampler()
|
||||
: Width(0)
|
||||
, Height(0)
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
Texture2DSampler(vtkm::Id width,
|
||||
vtkm::Id height,
|
||||
const TextureDataHandle& data,
|
||||
TextureFilterMode filterMode,
|
||||
TextureWrapMode wrapMode)
|
||||
: Width(width)
|
||||
, Height(height)
|
||||
, Data(data)
|
||||
, FilterMode(filterMode)
|
||||
, WrapMode(wrapMode)
|
||||
{
|
||||
this->DefaultConstructor = false;
|
||||
}
|
||||
|
||||
template <typename Device>
|
||||
VTKM_CONT Texture2DSamplerExecutionObject<Device> PrepareForExecution(Device) const
|
||||
{
|
||||
if (DefaultConstructor)
|
||||
{
|
||||
Texture2DSamplerExecutionObject<Device> ExecutionObject(
|
||||
this->Width, this->Height, this->Data, this->FilterMode, this->WrapMode);
|
||||
return ExecutionObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
Texture2DSamplerExecutionObject<Device> ExecutionObject;
|
||||
return ExecutionObject;
|
||||
}
|
||||
}
|
||||
|
||||
bool DefaultConstructor = true;
|
||||
vtkm::Id Width;
|
||||
vtkm::Id Height;
|
||||
TextureDataHandle Data;
|
||||
TextureFilterMode FilterMode;
|
||||
TextureWrapMode WrapMode;
|
||||
}; // class Texture2DSampler
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user