GPU: Make 1D textures into 2D ones.
This commit is contained in:
parent
1570dcd24c
commit
b14dc3351c
|
@ -34,7 +34,9 @@ bool TextureInfo::Prepare(const xe_gpu_texture_fetch_t& fetch,
|
||||||
info.width = info.height = info.depth = 0;
|
info.width = info.height = info.depth = 0;
|
||||||
switch (info.dimension) {
|
switch (info.dimension) {
|
||||||
case Dimension::k1D:
|
case Dimension::k1D:
|
||||||
|
info.dimension = Dimension::k2D;
|
||||||
info.width = fetch.size_1d.width;
|
info.width = fetch.size_1d.width;
|
||||||
|
info.height = 1;
|
||||||
break;
|
break;
|
||||||
case Dimension::k2D:
|
case Dimension::k2D:
|
||||||
info.width = fetch.size_2d.width;
|
info.width = fetch.size_2d.width;
|
||||||
|
@ -65,7 +67,7 @@ bool TextureInfo::Prepare(const xe_gpu_texture_fetch_t& fetch,
|
||||||
// Must be called here when we know the format.
|
// Must be called here when we know the format.
|
||||||
switch (info.dimension) {
|
switch (info.dimension) {
|
||||||
case Dimension::k1D: {
|
case Dimension::k1D: {
|
||||||
info.CalculateTextureSizes1D(fetch.size_1d.width + 1);
|
assert_always();
|
||||||
} break;
|
} break;
|
||||||
case Dimension::k2D: {
|
case Dimension::k2D: {
|
||||||
info.CalculateTextureSizes2D(fetch.size_2d.width + 1,
|
info.CalculateTextureSizes2D(fetch.size_2d.width + 1,
|
||||||
|
@ -112,36 +114,6 @@ bool TextureInfo::PrepareResolve(uint32_t physical_address,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureInfo::CalculateTextureSizes1D(uint32_t width) {
|
|
||||||
// ?
|
|
||||||
size_1d.logical_width = width;
|
|
||||||
|
|
||||||
auto format = format_info();
|
|
||||||
|
|
||||||
uint32_t block_width =
|
|
||||||
xe::round_up(size_1d.logical_width, format->block_width) /
|
|
||||||
format->block_width;
|
|
||||||
|
|
||||||
uint32_t tile_width = xe::round_up(block_width, 32) / 32;
|
|
||||||
size_1d.block_width = tile_width * 32;
|
|
||||||
|
|
||||||
uint32_t bytes_per_block = format->block_width * format->bits_per_pixel / 8;
|
|
||||||
uint32_t byte_pitch = tile_width * 32 * bytes_per_block;
|
|
||||||
|
|
||||||
uint32_t texel_width;
|
|
||||||
if (!is_tiled) {
|
|
||||||
// Each row must be a multiple of 256 in linear textures.
|
|
||||||
byte_pitch = xe::round_up(byte_pitch, 256);
|
|
||||||
texel_width = (byte_pitch / bytes_per_block) * format->block_width;
|
|
||||||
} else {
|
|
||||||
texel_width = tile_width * 32 * format->block_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_1d.input_width = texel_width;
|
|
||||||
size_1d.input_pitch = byte_pitch;
|
|
||||||
input_length = size_1d.input_pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextureInfo::CalculateTextureSizes2D(uint32_t width, uint32_t height) {
|
void TextureInfo::CalculateTextureSizes2D(uint32_t width, uint32_t height) {
|
||||||
size_2d.logical_width = width;
|
size_2d.logical_width = width;
|
||||||
size_2d.logical_height = height;
|
size_2d.logical_height = height;
|
||||||
|
|
|
@ -317,7 +317,6 @@ struct TextureInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CalculateTextureSizes1D(uint32_t width);
|
|
||||||
void CalculateTextureSizes2D(uint32_t width, uint32_t height);
|
void CalculateTextureSizes2D(uint32_t width, uint32_t height);
|
||||||
void CalculateTextureSizesCube(uint32_t width, uint32_t height,
|
void CalculateTextureSizesCube(uint32_t width, uint32_t height,
|
||||||
uint32_t depth);
|
uint32_t depth);
|
||||||
|
|
|
@ -198,8 +198,6 @@ TextureCache::Texture* TextureCache::AllocateTexture(
|
||||||
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
||||||
switch (texture_info.dimension) {
|
switch (texture_info.dimension) {
|
||||||
case Dimension::k1D:
|
case Dimension::k1D:
|
||||||
image_info.imageType = VK_IMAGE_TYPE_1D;
|
|
||||||
break;
|
|
||||||
case Dimension::k2D:
|
case Dimension::k2D:
|
||||||
image_info.imageType = VK_IMAGE_TYPE_2D;
|
image_info.imageType = VK_IMAGE_TYPE_2D;
|
||||||
break;
|
break;
|
||||||
|
@ -480,8 +478,6 @@ TextureCache::TextureView* TextureCache::DemandView(Texture* texture,
|
||||||
|
|
||||||
switch (texture->texture_info.dimension) {
|
switch (texture->texture_info.dimension) {
|
||||||
case Dimension::k1D:
|
case Dimension::k1D:
|
||||||
view_info.viewType = VK_IMAGE_VIEW_TYPE_1D;
|
|
||||||
break;
|
|
||||||
case Dimension::k2D:
|
case Dimension::k2D:
|
||||||
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
||||||
break;
|
break;
|
||||||
|
@ -771,26 +767,6 @@ void TextureCache::FlushPendingCommands(VkCommandBuffer command_buffer,
|
||||||
vkBeginCommandBuffer(command_buffer, &begin_info);
|
vkBeginCommandBuffer(command_buffer, &begin_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureCache::ConvertTexture1D(uint8_t* dest,
|
|
||||||
VkBufferImageCopy* copy_region,
|
|
||||||
const TextureInfo& src) {
|
|
||||||
void* host_address = memory_->TranslatePhysical(src.guest_address);
|
|
||||||
if (src.texture_format == TextureFormat::k_CTX1) {
|
|
||||||
assert_always();
|
|
||||||
} else {
|
|
||||||
if (!src.is_tiled) {
|
|
||||||
TextureSwap(src.endianness, dest, host_address, src.input_length);
|
|
||||||
copy_region->bufferRowLength = src.size_1d.input_width;
|
|
||||||
copy_region->bufferImageHeight = 1;
|
|
||||||
copy_region->imageExtent = {src.size_1d.logical_width, 1, 1};
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
assert_always();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TextureCache::ConvertTexture2D(uint8_t* dest,
|
bool TextureCache::ConvertTexture2D(uint8_t* dest,
|
||||||
VkBufferImageCopy* copy_region,
|
VkBufferImageCopy* copy_region,
|
||||||
const TextureInfo& src) {
|
const TextureInfo& src) {
|
||||||
|
@ -1053,7 +1029,7 @@ bool TextureCache::ConvertTexture(uint8_t* dest, VkBufferImageCopy* copy_region,
|
||||||
const TextureInfo& src) {
|
const TextureInfo& src) {
|
||||||
switch (src.dimension) {
|
switch (src.dimension) {
|
||||||
case Dimension::k1D:
|
case Dimension::k1D:
|
||||||
return ConvertTexture1D(dest, copy_region, src);
|
assert_always();
|
||||||
case Dimension::k2D:
|
case Dimension::k2D:
|
||||||
return ConvertTexture2D(dest, copy_region, src);
|
return ConvertTexture2D(dest, copy_region, src);
|
||||||
case Dimension::kCube:
|
case Dimension::kCube:
|
||||||
|
@ -1067,8 +1043,7 @@ bool TextureCache::ComputeTextureStorage(size_t* output_length,
|
||||||
if (src.texture_format == TextureFormat::k_CTX1) {
|
if (src.texture_format == TextureFormat::k_CTX1) {
|
||||||
switch (src.dimension) {
|
switch (src.dimension) {
|
||||||
case Dimension::k1D: {
|
case Dimension::k1D: {
|
||||||
*output_length = src.size_1d.input_width * 2;
|
assert_always();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case Dimension::k2D: {
|
case Dimension::k2D: {
|
||||||
*output_length = src.size_2d.input_width * src.size_2d.input_height * 2;
|
*output_length = src.size_2d.input_width * src.size_2d.input_height * 2;
|
||||||
|
|
|
@ -139,8 +139,6 @@ class TextureCache {
|
||||||
void FlushPendingCommands(VkCommandBuffer command_buffer,
|
void FlushPendingCommands(VkCommandBuffer command_buffer,
|
||||||
VkFence completion_fence);
|
VkFence completion_fence);
|
||||||
|
|
||||||
bool ConvertTexture1D(uint8_t* dest, VkBufferImageCopy* copy_region,
|
|
||||||
const TextureInfo& src);
|
|
||||||
bool ConvertTexture2D(uint8_t* dest, VkBufferImageCopy* copy_region,
|
bool ConvertTexture2D(uint8_t* dest, VkBufferImageCopy* copy_region,
|
||||||
const TextureInfo& src);
|
const TextureInfo& src);
|
||||||
bool ConvertTextureCube(uint8_t* dest, VkBufferImageCopy* copy_region,
|
bool ConvertTextureCube(uint8_t* dest, VkBufferImageCopy* copy_region,
|
||||||
|
|
Loading…
Reference in New Issue