Commit 35170f5c by Jamie Madill Committed by Commit Bot

Fix Renderer generator script.

This script breaks peridocially because we don't have automated tests for it. Split the FBO attachment object class into its own file, and also fix a couple other small snags that prevented the script from running. This will facilitate generating Vulkan renderer stubs. BUG=angleproject:1319 Change-Id: I30a6ce4ab0adad962cea76731dbe82837c5c9a1b Reviewed-on: https://chromium-review.googlesource.com/347064Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 25ab4510
......@@ -15,17 +15,18 @@
# grouped after the public destructor or after the private
# DISALLOW_COPY_AND_ASSIGN macro.
import os
import sys
import re
import string
import os, sys, re, string, datetime
if len(sys.argv) < 3:
print('Usage: ' + sys.argv[0] + ' <renderer name> <renderer suffix>')
print('Usage: ' + sys.argv[0] + ' <renderer dir name> <renderer class suffix>')
sys.exit(1)
renderer_name = sys.argv[1]
renderer_suffix = sys.argv[2]
# change to the renderer directory
os.chdir(os.path.join(os.path.dirname(sys.argv[0]), "..", "src", "libANGLE", "renderer"))
# ensure subdir exists
if not os.path.isdir(renderer_name):
os.mkdir(renderer_name)
......@@ -33,14 +34,17 @@ if not os.path.isdir(renderer_name):
impl_classes = [
'Buffer',
'Compiler',
'Context',
'Device',
'Display',
'FenceNV',
'FenceSync',
'Framebuffer',
'Image',
'Program',
'Query',
'Renderbuffer',
'Renderer',
'Sampler',
'Shader',
'Surface',
'Texture',
......@@ -49,12 +53,13 @@ impl_classes = [
]
h_file_template = """//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// $TypedImpl.h: Defines the class interface for $TypedImpl.
// $TypedImpl.h:
// Defines the class interface for $TypedImpl, implementing $BaseImpl.
//
#ifndef LIBANGLE_RENDERER_${RendererNameCaps}_${TypedImplCaps}_H_
#define LIBANGLE_RENDERER_${RendererNameCaps}_${TypedImplCaps}_H_
......@@ -71,18 +76,19 @@ class $TypedImpl : public $BaseImpl
~$TypedImpl() override;
$ImplMethodDeclarations$PrivateImplMethodDeclarations};
}
} // namespace rx
#endif // LIBANGLE_RENDERER_${RendererNameCaps}_${TypedImplCaps}_H_
#endif // LIBANGLE_RENDERER_${RendererNameCaps}_${TypedImplCaps}_H_
"""
cpp_file_template = """//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Copyright $Year The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// $TypedImpl.cpp: Implements the class methods for $TypedImpl.
// $TypedImpl.cpp:
// Implements the class methods for $TypedImpl.
//
#include "libANGLE/renderer/$RendererName/$TypedImpl.h"
......@@ -91,14 +97,15 @@ cpp_file_template = """//
namespace rx
{
$TypedImpl::$TypedImpl($ConstructorParams)
: $BaseImpl($BaseContructorArgs)
{}
$TypedImpl::$TypedImpl($ConstructorParams) : $BaseImpl($BaseContructorArgs)
{
}
$TypedImpl::~$TypedImpl()
{}
$ImplMethodDefinitions
{
}
$ImplMethodDefinitions
} // namespace rx
"""
def generate_impl_declaration(impl_stub):
......@@ -134,8 +141,11 @@ def generate_impl_definition(impl_stub, typed_impl):
return_statement = ' return egl::Error(EGL_BAD_ACCESS);\n'
elif return_type == 'LinkResult':
return_statement = ' return LinkResult(false, gl::Error(GL_INVALID_OPERATION));\n'
elif re.search(r'[\*\&]$', return_type):
elif re.search(r'\*$', return_type):
return_statement = ' return static_cast<' + return_type + '>(0);\n'
elif re.search(r'const ([^ \&]+) \&$', return_type):
obj_type = re.search(r'const ([^ \&]+) \&$', return_type).group(1)
return_statement = ' static ' + obj_type + ' local;\n' + ' return local;\n'
else:
return_statement = ' return ' + return_type + '();\n'
......@@ -189,14 +199,18 @@ def parse_impl_header(base_impl):
return impl_stubs, private_impl_stubs, constructor
for impl_class in impl_classes:
base_impl = impl_class
def get_base_class(base_impl):
impl_h_file_path = base_impl + '.h'
with open(impl_h_file_path, 'r') as impl_h_file:
for line in impl_h_file:
match = re.search(r'^class ' + base_impl + r' : public (\w+)', line)
if match:
return match.group(1)
return False
# special case for Renderer
if impl_class != 'Renderer':
base_impl += 'Impl'
for impl_class in impl_classes:
base_impl = impl_class + 'Impl'
typed_impl = impl_class + renderer_suffix
h_file_path = os.path.join(renderer_name, typed_impl + '.h')
......@@ -208,10 +222,10 @@ for impl_class in impl_classes:
# extract impl stubs
impl_stubs, private_impl_stubs, constructor = parse_impl_header(base_impl)
# more special case for Renderer
# TODO(jmadill): general case for base classes
if impl_class == 'Renderer':
base_impl_stubs, base_private_impl_stubs, base_constructor = parse_impl_header('ImplFactory')
# Handle base classes, skipping angle::NonCopyable.
base_class = get_base_class(base_impl)
if base_class and base_class != 'angle':
base_impl_stubs, base_private_impl_stubs, base_constructor = parse_impl_header(base_class)
impl_stubs += base_impl_stubs
private_impl_stubs += base_private_impl_stubs
......@@ -249,6 +263,7 @@ for impl_class in impl_classes:
'ConstructorParams': constructor_params,
'BaseContructorArgs': base_constructor_args,
'PrivateImplMethodDeclarations': private_impl_method_declarations,
'Year': datetime.datetime.now().year,
}
h_file.write(string.Template(h_file_template).substitute(substitutions))
......@@ -256,3 +271,10 @@ for impl_class in impl_classes:
h_file.close()
cpp_file.close()
# Print a block of source files to add to the GYP
print("Generated files:")
for impl_class in impl_classes:
path = "libANGLE/renderer/" + renderer_name + "/" + impl_class + renderer_suffix
print('\'' + path + ".cpp\',")
print('\'' + path + ".h\',")
......@@ -16,6 +16,7 @@
#include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/FramebufferImpl.h"
#include "libANGLE/renderer/FramebufferAttachmentObjectImpl.h"
namespace gl
{
......@@ -225,4 +226,11 @@ bool FramebufferAttachment::operator!=(const FramebufferAttachment &other) const
return !(*this == other);
}
Error FramebufferAttachmentObject::getAttachmentRenderTarget(
const FramebufferAttachment::Target &target,
rx::FramebufferAttachmentRenderTarget **rtOut) const
{
return getAttachmentImpl()->getAttachmentRenderTarget(target, rtOut);
}
} // namespace gl
......@@ -191,31 +191,4 @@ inline gl::Error FramebufferAttachment::getRenderTarget(rx::FramebufferAttachmen
} // namespace gl
namespace rx
{
class FramebufferAttachmentObjectImpl : angle::NonCopyable
{
public:
FramebufferAttachmentObjectImpl() {}
virtual ~FramebufferAttachmentObjectImpl() {}
virtual gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) = 0;
};
} // namespace rx
namespace gl
{
inline Error FramebufferAttachmentObject::getAttachmentRenderTarget(
const FramebufferAttachment::Target &target,
rx::FramebufferAttachmentRenderTarget **rtOut) const
{
return getAttachmentImpl()->getAttachmentRenderTarget(target, rtOut);
}
}
#endif // LIBANGLE_FRAMEBUFFERATTACHMENT_H_
......@@ -23,9 +23,12 @@ class BufferImpl : angle::NonCopyable
public:
virtual ~BufferImpl() { }
virtual gl::Error setData(const void* data, size_t size, GLenum usage) = 0;
virtual gl::Error setSubData(const void* data, size_t size, size_t offset) = 0;
virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0;
virtual gl::Error setData(const void *data, size_t size, GLenum usage) = 0;
virtual gl::Error setSubData(const void *data, size_t size, size_t offset) = 0;
virtual gl::Error copySubData(BufferImpl *source,
GLintptr sourceOffset,
GLintptr destOffset,
GLsizeiptr size) = 0;
virtual gl::Error map(GLenum access, GLvoid **mapPtr) = 0;
virtual gl::Error mapRange(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) = 0;
virtual gl::Error unmap(GLboolean *result) = 0;
......
......@@ -24,14 +24,6 @@ class ContextImpl : public GLImplFactory
virtual gl::Error initialize() = 0;
const gl::ContextState &getContextState() { return mState; }
int getClientVersion() const { return mState.clientVersion; }
const gl::State &getState() const { return *mState.state; }
const gl::Caps &getCaps() const { return *mState.caps; }
const gl::TextureCapsMap &getTextureCaps() const { return *mState.textureCaps; }
const gl::Extensions &getExtensions() const { return *mState.extensions; }
const gl::Limitations &getLimitations() const { return *mState.limitations; }
// Flush and finish.
virtual gl::Error flush() = 0;
virtual gl::Error finish() = 0;
......@@ -93,6 +85,14 @@ class ContextImpl : public GLImplFactory
virtual const gl::Extensions &getNativeExtensions() const = 0;
virtual const gl::Limitations &getNativeLimitations() const = 0;
const gl::ContextState &getContextState() { return mState; }
int getClientVersion() const { return mState.clientVersion; }
const gl::State &getState() const { return *mState.state; }
const gl::Caps &getCaps() const { return *mState.caps; }
const gl::TextureCapsMap &getTextureCaps() const { return *mState.textureCaps; }
const gl::Extensions &getExtensions() const { return *mState.extensions; }
const gl::Limitations &getLimitations() const { return *mState.limitations; }
protected:
const gl::ContextState &mState;
};
......
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FramebufferAttachmentObjectImpl.h:
// Common ancenstor for all implementations of FBO attachable-objects.
// This means Surfaces, Textures and Renderbuffers.
//
#ifndef LIBANGLE_RENDERER_FRAMEBUFFER_ATTACHMENT_OBJECT_IMPL_H_
#define LIBANGLE_RENDERER_FRAMEBUFFER_ATTACHMENT_OBJECT_IMPL_H_
#include "libANGLE/FramebufferAttachment.h"
namespace rx
{
class FramebufferAttachmentObjectImpl : angle::NonCopyable
{
public:
FramebufferAttachmentObjectImpl() {}
virtual ~FramebufferAttachmentObjectImpl() {}
virtual gl::Error getAttachmentRenderTarget(const gl::FramebufferAttachment::Target &target,
FramebufferAttachmentRenderTarget **rtOut) = 0;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_FRAMEBUFFER_ATTACHMENT_OBJECT_IMPL_H_
......@@ -12,7 +12,7 @@
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/renderer/FramebufferAttachmentObjectImpl.h"
namespace egl
{
......
......@@ -12,6 +12,7 @@
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/renderer/FramebufferAttachmentObjectImpl.h"
namespace gl
{
......
......@@ -14,9 +14,9 @@
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/ImageIndex.h"
#include "libANGLE/Stream.h"
#include "libANGLE/renderer/FramebufferAttachmentObjectImpl.h"
namespace egl
{
......
......@@ -146,6 +146,7 @@
'libANGLE/renderer/EGLImplFactory.h',
'libANGLE/renderer/FenceNVImpl.h',
'libANGLE/renderer/FenceSyncImpl.h',
'libANGLE/renderer/FramebufferAttachmentObjectImpl.h',
'libANGLE/renderer/FramebufferImpl.h',
'libANGLE/renderer/GLImplFactory.h',
'libANGLE/renderer/ImageImpl.h',
......
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