增加Device::CreateSampler
This commit is contained in:
parent
f5d86f6c32
commit
0879f7fad3
@ -27,6 +27,8 @@ class Texture3D;
|
||||
class TextureCubemap;
|
||||
class TextureCubemapArray;
|
||||
|
||||
class Sampler;
|
||||
|
||||
class Buffer;
|
||||
class VertexBuffer;
|
||||
class IndexBuffer;
|
||||
|
@ -89,6 +89,7 @@ public: //Buffer相关
|
||||
public: //material相关
|
||||
|
||||
Texture2D *CreateTexture2D(const VkFormat video_format,void *data,uint32_t width,uint32_t height,uint32_t size,bool force_linear=false);
|
||||
Sampler *CreateSampler(VkSamplerCreateInfo *);
|
||||
|
||||
ShaderModuleManage *CreateShaderModuleManage();
|
||||
|
||||
|
31
inc/hgl/graph/vulkan/VKSampler.h
Normal file
31
inc/hgl/graph/vulkan/VKSampler.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_SAMPLER_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_SAMPLER_INCLUDE
|
||||
|
||||
#include<hgl/graph/vulkan/VK.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
class Device;
|
||||
|
||||
class Sampler
|
||||
{
|
||||
VkDevice device;
|
||||
VkSampler sampler;
|
||||
|
||||
protected:
|
||||
|
||||
friend class Device;
|
||||
|
||||
Sampler(VkDevice dev,VkSampler s)
|
||||
{
|
||||
device=dev;
|
||||
sampler=s;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
~Sampler();
|
||||
|
||||
operator VkSampler(){return sampler;}
|
||||
operator const VkSampler()const{return sampler;}
|
||||
};//class Sampler
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SAMPLER_INCLUDE
|
@ -23,7 +23,7 @@ public:
|
||||
|
||||
operator VkImage (){return data?data->image:nullptr;}
|
||||
operator VkImageLayout (){return data?data->image_layout:VK_IMAGE_LAYOUT_UNDEFINED;}
|
||||
operator VkImageView (){return data?*(data->image_view):nullptr;}
|
||||
operator ImageView * (){return data?data->image_view:nullptr;}
|
||||
|
||||
const uint32 GetMipLevels()const{return data?data->mip_levels:0;}
|
||||
const bool IsLinear ()const{return data?data->linear:false;}
|
||||
@ -57,6 +57,9 @@ public:
|
||||
|
||||
Texture2D(uint32_t w,uint32_t h,VkDevice dev,TextureData *td):width(w),height(h),Texture(dev,td){}
|
||||
~Texture2D()=default;
|
||||
|
||||
const uint32_t GetWidth()const{return width;}
|
||||
const uint32_t GetHeight()const{return height;}
|
||||
};//class Texture2D:public Texture
|
||||
|
||||
//class Texture2DArray:public Texture
|
||||
|
@ -22,7 +22,8 @@
|
||||
${ROOT_INCLUDE_PATH}/hgl/graph/vulkan/VKShaderModuleManage.h
|
||||
${ROOT_INCLUDE_PATH}/hgl/graph/vulkan/VKSurfaceExtensionName.h
|
||||
${ROOT_INCLUDE_PATH}/hgl/graph/vulkan/VKVertexAttributeBinding.h
|
||||
${ROOT_INCLUDE_PATH}/hgl/graph/vulkan/VKTexture.h)
|
||||
${ROOT_INCLUDE_PATH}/hgl/graph/vulkan/VKTexture.h
|
||||
${ROOT_INCLUDE_PATH}/hgl/graph/vulkan/VKSampler.h)
|
||||
|
||||
SET(RENDER_DEVICE_VULKAN_SOURCE VKFormat.cpp
|
||||
VKInstance.cpp
|
||||
@ -49,7 +50,8 @@ SET(RENDER_DEVICE_VULKAN_SOURCE VKFormat.cpp
|
||||
VKFence.cpp
|
||||
VKMaterial.cpp
|
||||
VKRenderable.cpp
|
||||
VKTexture.cpp)
|
||||
VKTexture.cpp
|
||||
VKSampler.cpp)
|
||||
|
||||
SET(RENDER_DEVICE_VULKAN_POD_SOURCE pod/VKPipelineCreateInfo.POD.cpp)
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include<hgl/graph/vulkan/VKTexture.h>
|
||||
#include<hgl/graph/vulkan/VKSampler.h>
|
||||
#include<hgl/graph/vulkan/VKDevice.h>
|
||||
#include<hgl/graph/vulkan/VKPhysicalDevice.h>
|
||||
#include<hgl/graph/vulkan/VKBuffer.h>
|
||||
@ -146,6 +147,29 @@ Texture2D *Device::CreateTexture2D(const VkFormat video_format,void *data,uint32
|
||||
#undef VK_CHECK_RESULT
|
||||
}
|
||||
|
||||
return(new Texture2D(width,height,tex_data));
|
||||
return(new Texture2D(width,height,attr->device,tex_data));
|
||||
}
|
||||
|
||||
Sampler *Device::CreateSampler(VkSamplerCreateInfo *sci)
|
||||
{
|
||||
if(!sci)return(nullptr);
|
||||
|
||||
VkSampler sampler;
|
||||
|
||||
if(attr->physical_device->features.samplerAnisotropy)
|
||||
{
|
||||
sci->maxAnisotropy = attr->physical_device->properties.limits.maxSamplerAnisotropy;
|
||||
sci->anisotropyEnable = VK_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
sci->maxAnisotropy = 1.0;
|
||||
sci->anisotropyEnable = VK_FALSE;
|
||||
}
|
||||
|
||||
if(vkCreateSampler(attr->device,sci,nullptr,&sampler)!=VK_SUCCESS)
|
||||
return(nullptr);
|
||||
|
||||
return(new Sampler(attr->device,sampler));
|
||||
}
|
||||
VK_NAMESPACE_END
|
||||
|
7
src/RenderDevice/Vulkan/VKSampler.cpp
Normal file
7
src/RenderDevice/Vulkan/VKSampler.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include<hgl/graph/vulkan/VKSampler.h>
|
||||
VK_NAMESPACE_BEGIN
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
vkDestroySampler(device,sampler,nullptr);
|
||||
}
|
||||
VK_NAMESPACE_END
|
Loading…
x
Reference in New Issue
Block a user