Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: gpu/command_buffer/client/cmd_buffer_helper.h

Issue 427003008: Use placement new to allocate GPU command buffer entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/client/cmd_buffer_helper.h
diff --git a/gpu/command_buffer/client/cmd_buffer_helper.h b/gpu/command_buffer/client/cmd_buffer_helper.h
index 954107f1590a6b0816146b93dfeb6d2fb9199758..404d68d49ddf372bfe98b4aebb1cc1d090a35dea 100644
--- a/gpu/command_buffer/client/cmd_buffer_helper.h
+++ b/gpu/command_buffer/client/cmd_buffer_helper.h
@@ -135,27 +135,13 @@ class GPU_EXPORT CommandBufferHelper {
return space;
}
- template <typename T>
- void ForceNullCheck(T* data) {
-#if defined(OS_WIN) && defined(ARCH_CPU_64_BITS)
- // 64-bit MSVC's alias analysis was determining that the command buffer
- // entry couldn't be NULL, so it optimized out the NULL check.
- // Dereferencing the same datatype through a volatile pointer seems to
- // prevent that from happening. http://crbug.com/361936
- if (data)
- static_cast<volatile T*>(data)->header;
-#endif
- }
-
// Typed version of GetSpace. Gets enough room for the given type and returns
// a reference to it.
template <typename T>
T* GetCmdSpace() {
COMPILE_ASSERT(T::kArgFlags == cmd::kFixed, Cmd_kArgFlags_not_kFixed);
int32 space_needed = ComputeNumEntries(sizeof(T));
- T* data = static_cast<T*>(GetSpace(space_needed));
- ForceNullCheck(data);
- return data;
+ return new (GetSpace(space_needed)) T;
}
// Typed version of GetSpace for immediate commands.
@@ -163,9 +149,7 @@ class GPU_EXPORT CommandBufferHelper {
T* GetImmediateCmdSpace(size_t data_space) {
COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
int32 space_needed = ComputeNumEntries(sizeof(T) + data_space);
- T* data = static_cast<T*>(GetSpace(space_needed));
- ForceNullCheck(data);
- return data;
+ return new (GetSpace(space_needed)) T;
}
// Typed version of GetSpace for immediate commands.
@@ -173,9 +157,7 @@ class GPU_EXPORT CommandBufferHelper {
T* GetImmediateCmdSpaceTotalSize(size_t total_space) {
COMPILE_ASSERT(T::kArgFlags == cmd::kAtLeastN, Cmd_kArgFlags_not_kAtLeastN);
int32 space_needed = ComputeNumEntries(total_space);
- T* data = static_cast<T*>(GetSpace(space_needed));
- ForceNullCheck(data);
- return data;
+ return new (GetSpace(space_needed)) T;
}
int32 last_token_read() const {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698