TextureData增加初始值设置
This commit is contained in:
parent
e42e721553
commit
946cef0e11
@ -93,7 +93,7 @@ public: //Buffer相关
|
|||||||
|
|
||||||
public: //material相关
|
public: //material相关
|
||||||
|
|
||||||
Texture2D *CreateRefTexture2D(uint32_t width,uint32_t height,VkFormat format,VkImageAspectFlagBits flag,VkImage image,VkImageView image_view);
|
Texture2D *CreateRefTexture2D(uint32_t width,uint32_t height,VkFormat format,VkImageAspectFlagBits flag,VkImage image,VkImageLayout image_layout,VkImageView image_view);
|
||||||
|
|
||||||
Texture2D *CreateTexture2D(const VkFormat video_format,void *data,uint32_t width,uint32_t height,uint32_t size,bool force_linear=false);
|
Texture2D *CreateTexture2D(const VkFormat video_format,void *data,uint32_t width,uint32_t height,uint32_t size,bool force_linear=false);
|
||||||
bool ChangeTexture2D(Texture2D *,void *data,uint32_t left,uint32_t top,uint32_t width,uint32_t height,uint32_t size);
|
bool ChangeTexture2D(Texture2D *,void *data,uint32_t left,uint32_t top,uint32_t width,uint32_t height,uint32_t size);
|
||||||
|
@ -6,21 +6,14 @@
|
|||||||
VK_NAMESPACE_BEGIN
|
VK_NAMESPACE_BEGIN
|
||||||
struct TextureData
|
struct TextureData
|
||||||
{
|
{
|
||||||
VkDeviceMemory memory;
|
VkDeviceMemory memory =nullptr;
|
||||||
VkImage image;
|
VkImage image =nullptr;
|
||||||
VkImageLayout image_layout;
|
VkImageLayout image_layout=VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
ImageView *image_view;
|
ImageView * image_view =nullptr;
|
||||||
uint32 mip_levels;
|
uint32 mip_levels =0;
|
||||||
bool linear;
|
bool linear =false;
|
||||||
|
|
||||||
bool ref; //是否是引用
|
bool ref =false; //是否是引用
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
TextureData(bool r=false)
|
|
||||||
{
|
|
||||||
ref=r;
|
|
||||||
}
|
|
||||||
};//struct TextureData
|
};//struct TextureData
|
||||||
|
|
||||||
class Texture
|
class Texture
|
||||||
|
@ -45,14 +45,10 @@ Texture2D *Device::CreateTexture2D(const VkFormat video_format,void *data,uint32
|
|||||||
return(nullptr); //这个我们暂时不支持
|
return(nullptr); //这个我们暂时不支持
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureData *tex_data=new TextureData(false);
|
TextureData *tex_data=new TextureData;
|
||||||
|
|
||||||
tex_data->memory=nullptr;
|
|
||||||
tex_data->image=nullptr;
|
|
||||||
tex_data->image_view=nullptr;
|
|
||||||
|
|
||||||
|
tex_data->ref =false;
|
||||||
tex_data->mip_levels=1;
|
tex_data->mip_levels=1;
|
||||||
tex_data->linear=false;
|
|
||||||
|
|
||||||
if(force_linear)
|
if(force_linear)
|
||||||
{
|
{
|
||||||
@ -163,12 +159,15 @@ Texture2D *Device::CreateTexture2D(const VkFormat video_format,void *data,uint32
|
|||||||
return(new Texture2D(width,height,attr->device,tex_data));
|
return(new Texture2D(width,height,attr->device,tex_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D *Device::CreateRefTexture2D(uint32_t width,uint32_t height,VkFormat format,VkImageAspectFlagBits flag,VkImage image,VkImageView image_view)
|
Texture2D *Device::CreateRefTexture2D(uint32_t width,uint32_t height,VkFormat format,VkImageAspectFlagBits flag,VkImage image,VkImageLayout image_layout,VkImageView image_view)
|
||||||
{
|
{
|
||||||
TextureData *tex_data=new TextureData(true);
|
TextureData *tex_data=new TextureData;
|
||||||
|
|
||||||
|
tex_data->ref =true;
|
||||||
|
|
||||||
tex_data->memory =nullptr;
|
tex_data->memory =nullptr;
|
||||||
tex_data->image =image;
|
tex_data->image =image;
|
||||||
|
tex_data->image_layout =image_layout;
|
||||||
tex_data->image_view =CreateRefImageView(attr->device,VK_IMAGE_VIEW_TYPE_2D,format,flag,image_view);
|
tex_data->image_view =CreateRefImageView(attr->device,VK_IMAGE_VIEW_TYPE_2D,format,flag,image_view);
|
||||||
|
|
||||||
tex_data->mip_levels =0;
|
tex_data->mip_levels =0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user