Commit 6816d843 by Jamie Madill Committed by Commit Bot

Add two new fields to angle::Format.

One field determines if a format is a compressed format (called Block format for angle::Format, but basically the same). The second field is the number of bytes in the format, so we can do calculations on pixel size. Both of these will make life cleaner in the Vulkan back-end. Also solves some TODOs in the vk format table init. Bug: angleproject:2318 Bug: angleproject:2358 Change-Id: I8b021b959c5892c86635e0225012295e5e830256 Reviewed-on: https://chromium-review.googlesource.com/987524 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarFrank Henigman <fjhenigman@chromium.org>
parent 9cceac42
...@@ -34,7 +34,9 @@ struct Format final : private angle::NonCopyable ...@@ -34,7 +34,9 @@ struct Format final : private angle::NonCopyable
GLuint blueBits, GLuint blueBits,
GLuint alphaBits, GLuint alphaBits,
GLuint depthBits, GLuint depthBits,
GLuint stencilBits); GLuint stencilBits,
GLuint pixelBytes,
bool isBlock);
static const Format &Get(ID id); static const Format &Get(ID id);
static ID InternalFormatToID(GLenum internalFormat); static ID InternalFormatToID(GLenum internalFormat);
...@@ -65,6 +67,10 @@ struct Format final : private angle::NonCopyable ...@@ -65,6 +67,10 @@ struct Format final : private angle::NonCopyable
GLuint alphaBits; GLuint alphaBits;
GLuint depthBits; GLuint depthBits;
GLuint stencilBits; GLuint stencilBits;
GLuint pixelBytes;
bool isBlock;
}; };
constexpr Format::Format(ID id, constexpr Format::Format(ID id,
...@@ -80,7 +86,9 @@ constexpr Format::Format(ID id, ...@@ -80,7 +86,9 @@ constexpr Format::Format(ID id,
GLuint blueBits, GLuint blueBits,
GLuint alphaBits, GLuint alphaBits,
GLuint depthBits, GLuint depthBits,
GLuint stencilBits) GLuint stencilBits,
GLuint pixelBytes,
bool isBlock)
: id(id), : id(id),
glInternalFormat(glFormat), glInternalFormat(glFormat),
fboImplementationInternalFormat(fboFormat), fboImplementationInternalFormat(fboFormat),
...@@ -94,7 +102,9 @@ constexpr Format::Format(ID id, ...@@ -94,7 +102,9 @@ constexpr Format::Format(ID id,
blueBits(blueBits), blueBits(blueBits),
alphaBits(alphaBits), alphaBits(alphaBits),
depthBits(depthBits), depthBits(depthBits),
stencilBits(stencilBits) stencilBits(stencilBits),
pixelBytes(pixelBytes),
isBlock(isBlock)
{ {
} }
......
...@@ -63,7 +63,7 @@ static constexpr rx::FastCopyFunctionMap NoCopyFunctions; ...@@ -63,7 +63,7 @@ static constexpr rx::FastCopyFunctionMap NoCopyFunctions;
constexpr Format g_formatInfoTable[] = {{ constexpr Format g_formatInfoTable[] = {{
// clang-format off // clang-format off
{{ Format::ID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0 }}, {{ Format::ID::NONE, GL_NONE, GL_NONE, nullptr, NoCopyFunctions, nullptr, nullptr, GL_NONE, 0, 0, 0, 0, 0, 0, 0, false }},
{angle_format_info_cases} // clang-format on {angle_format_info_cases} // clang-format on
}}; }};
...@@ -146,7 +146,7 @@ def get_color_write_function(angle_format): ...@@ -146,7 +146,7 @@ def get_color_write_function(angle_format):
return 'WriteColor<' + channel_struct + ', '+ write_component_type + '>' return 'WriteColor<' + channel_struct + ', '+ write_component_type + '>'
format_entry_template = """ {{ Format::ID::{id}, {glInternalFormat}, {fboImplementationInternalFormat}, {mipGenerationFunction}, {fastCopyFunctions}, {colorReadFunction}, {colorWriteFunction}, {namedComponentType}, {R}, {G}, {B}, {A}, {D}, {S} }}, format_entry_template = """ {{ Format::ID::{id}, {glInternalFormat}, {fboImplementationInternalFormat}, {mipGenerationFunction}, {fastCopyFunctions}, {colorReadFunction}, {colorWriteFunction}, {namedComponentType}, {R}, {G}, {B}, {A}, {D}, {S}, {pixelBytes}, {isBlock} }},
""" """
def get_named_component_type(component_type): def get_named_component_type(component_type):
...@@ -208,6 +208,12 @@ def json_to_table_data(format_id, json, angle_to_gl): ...@@ -208,6 +208,12 @@ def json_to_table_data(format_id, json, angle_to_gl):
if format_id == "B8G8R8A8_UNORM": if format_id == "B8G8R8A8_UNORM":
parsed["fastCopyFunctions"] = "BGRACopyFunctions" parsed["fastCopyFunctions"] = "BGRACopyFunctions"
sum_of_bits = 0
for channel in ["R", "G", "B", "A", "D", "S"]:
sum_of_bits += int(parsed[channel])
parsed["pixelBytes"] = sum_of_bits / 8
parsed["isBlock"] = "true" if format_id.endswith("_BLOCK") else "false"
return format_entry_template.format(**parsed) return format_entry_template.format(**parsed)
def parse_angle_format_table(all_angle, json_data, angle_to_gl): def parse_angle_format_table(all_angle, json_data, angle_to_gl):
......
...@@ -278,10 +278,7 @@ gl::Error FramebufferVk::readPixels(const gl::Context *context, ...@@ -278,10 +278,7 @@ gl::Error FramebufferVk::readPixels(const gl::Context *context,
0, &mapPointer)); 0, &mapPointer));
const angle::Format &angleFormat = renderTarget->image->getFormat().textureFormat(); const angle::Format &angleFormat = renderTarget->image->getFormat().textureFormat();
GLuint outputPitch = angleFormat.pixelBytes * area.width;
// TODO(jmadill): Use pixel bytes from the ANGLE format directly.
const auto &glFormat = gl::GetSizedInternalFormatInfo(angleFormat.glInternalFormat);
int outputPitch = glFormat.pixelBytes * area.width;
// Get the staging image pitch and use it to pack the pixels later. // Get the staging image pitch and use it to pack the pixels later.
VkSubresourceLayout subresourceLayout; VkSubresourceLayout subresourceLayout;
......
...@@ -125,8 +125,6 @@ void FormatTable::initialize(VkPhysicalDevice physicalDevice, ...@@ -125,8 +125,6 @@ void FormatTable::initialize(VkPhysicalDevice physicalDevice,
if (!mFormatData[formatIndex].valid()) if (!mFormatData[formatIndex].valid())
{ {
// TODO(lucferron): Implement support for more OpenGL Texture formats
// http://anglebug.com/2358
continue; continue;
} }
...@@ -140,9 +138,7 @@ void FormatTable::initialize(VkPhysicalDevice physicalDevice, ...@@ -140,9 +138,7 @@ void FormatTable::initialize(VkPhysicalDevice physicalDevice,
FillTextureFormatCaps(formatProperties, &textureCaps); FillTextureFormatCaps(formatProperties, &textureCaps);
outTextureCapsMap->set(formatID, textureCaps); outTextureCapsMap->set(formatID, textureCaps);
// TODO(lucferron): Optimize this by including compressed bool in the FormatID if (angleFormat.isBlock)
// http://anglebug.com/2358
if (gl::GetSizedInternalFormatInfo(internalFormat).compressed)
{ {
outCompressedTextureFormats->push_back(internalFormat); outCompressedTextureFormats->push_back(internalFormat);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment