[GPU] Use the pitch field in tfetch constants
This commit is contained in:
parent
f591f2dace
commit
191dc30bee
|
@ -34,6 +34,7 @@ bool TextureInfo::Prepare(const xe_gpu_texture_fetch_t& fetch,
|
|||
info.guest_address = fetch.address << 12;
|
||||
|
||||
info.dimension = static_cast<Dimension>(fetch.dimension);
|
||||
info.pitch = fetch.pitch << 5;
|
||||
info.width = info.height = info.depth = 0;
|
||||
switch (info.dimension) {
|
||||
case Dimension::k1D:
|
||||
|
@ -96,14 +97,15 @@ bool TextureInfo::Prepare(const xe_gpu_texture_fetch_t& fetch,
|
|||
|
||||
bool TextureInfo::PrepareResolve(uint32_t physical_address,
|
||||
TextureFormat texture_format, Endian endian,
|
||||
uint32_t width, uint32_t height,
|
||||
TextureInfo* out_info) {
|
||||
uint32_t pitch, uint32_t width,
|
||||
uint32_t height, TextureInfo* out_info) {
|
||||
std::memset(out_info, 0, sizeof(TextureInfo));
|
||||
auto& info = *out_info;
|
||||
info.guest_address = physical_address;
|
||||
info.dimension = Dimension::k2D;
|
||||
assert_true(width > 0);
|
||||
assert_true(height > 0);
|
||||
info.pitch = pitch;
|
||||
info.width = width - 1;
|
||||
info.height = height - 1;
|
||||
info.texture_format = texture_format;
|
||||
|
@ -148,15 +150,14 @@ void TextureInfo::CalculateTextureSizes1D(uint32_t width) {
|
|||
}
|
||||
|
||||
size.input_width = texel_width;
|
||||
size.input_pitch = byte_pitch;
|
||||
|
||||
// Set some reasonable defaults for unused fields.
|
||||
size.logical_height = 1;
|
||||
size.block_height = format->block_height;
|
||||
size.input_height = 1;
|
||||
size.input_face_length = size.input_pitch;
|
||||
size.input_face_length = pitch * bytes_per_block;
|
||||
|
||||
input_length = size.input_pitch;
|
||||
input_length = size.input_face_length;
|
||||
}
|
||||
|
||||
void TextureInfo::CalculateTextureSizes2D(uint32_t width, uint32_t height) {
|
||||
|
@ -192,8 +193,7 @@ void TextureInfo::CalculateTextureSizes2D(uint32_t width, uint32_t height) {
|
|||
|
||||
size.input_width = texel_width;
|
||||
size.input_height = size.block_height * format->block_height;
|
||||
size.input_pitch = byte_pitch;
|
||||
size.input_face_length = size.input_pitch * size.block_height;
|
||||
size.input_face_length = pitch * bytes_per_block * size.block_height;
|
||||
|
||||
input_length = size.input_face_length;
|
||||
}
|
||||
|
@ -232,8 +232,7 @@ void TextureInfo::CalculateTextureSizes3D(uint32_t width, uint32_t height,
|
|||
|
||||
size.input_width = texel_width;
|
||||
size.input_height = size.block_height * format->block_height;
|
||||
size.input_pitch = byte_pitch;
|
||||
size.input_face_length = size.input_pitch * size.block_height;
|
||||
size.input_face_length = pitch * bytes_per_block * size.block_height;
|
||||
|
||||
input_length = size.input_face_length * depth;
|
||||
}
|
||||
|
@ -273,10 +272,9 @@ void TextureInfo::CalculateTextureSizesCube(uint32_t width, uint32_t height,
|
|||
|
||||
size.input_width = texel_width;
|
||||
size.input_height = size.block_height * format->block_height;
|
||||
size.input_pitch = byte_pitch;
|
||||
size.input_face_length = size.input_pitch * size.block_height;
|
||||
size.input_face_length = pitch * bytes_per_block * size.block_height;
|
||||
|
||||
input_length = size.input_face_length * 6;
|
||||
input_length = size.input_face_length * depth;
|
||||
}
|
||||
|
||||
static void TextureSwap(Endian endianness, void* dest, const void* src,
|
||||
|
|
|
@ -250,9 +250,10 @@ struct TextureInfo {
|
|||
uint32_t guest_address;
|
||||
TextureFormat texture_format;
|
||||
Dimension dimension;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t depth;
|
||||
uint32_t pitch; // pitch in blocks
|
||||
uint32_t width; // width in pixels
|
||||
uint32_t height; // height in pixels
|
||||
uint32_t depth; // depth in layers
|
||||
Endian endianness;
|
||||
bool is_tiled;
|
||||
bool has_packed_mips;
|
||||
|
@ -265,10 +266,9 @@ struct TextureInfo {
|
|||
uint32_t logical_height;
|
||||
uint32_t block_width; // # of horizontal blocks
|
||||
uint32_t block_height; // # of vertical blocks
|
||||
uint32_t input_width; // texel pitch
|
||||
uint32_t input_height; // texel height
|
||||
uint32_t input_pitch; // byte pitch
|
||||
uint32_t input_face_length; // byte pitch of face
|
||||
uint32_t input_width; // (full) texel pitch
|
||||
uint32_t input_height; // (full) texel height
|
||||
uint32_t input_face_length; // byte length of face
|
||||
} size;
|
||||
|
||||
const FormatInfo* format_info() const {
|
||||
|
@ -284,7 +284,7 @@ struct TextureInfo {
|
|||
|
||||
static bool PrepareResolve(uint32_t physical_address,
|
||||
TextureFormat texture_format, Endian endian,
|
||||
uint32_t width, uint32_t height,
|
||||
uint32_t pitch, uint32_t width, uint32_t height,
|
||||
TextureInfo* out_info);
|
||||
|
||||
static void ConvertTiled(uint8_t* dest, const uint8_t* src, Endian endian,
|
||||
|
|
|
@ -831,8 +831,8 @@ TextureCache::Texture* TextureCache::LookupAddress(uint32_t guest_address,
|
|||
|
||||
if (texture_info.dimension == Dimension::k2D) {
|
||||
out_offset->x = 0;
|
||||
out_offset->y = offset_bytes / texture_info.size.input_pitch;
|
||||
if (offset_bytes % texture_info.size.input_pitch != 0) {
|
||||
out_offset->y = offset_bytes / texture_info.pitch;
|
||||
if (offset_bytes % texture_info.pitch != 0) {
|
||||
// TODO: offset_x
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue