Chromium Code Reviews| Index: gpu/command_buffer/service/memory_shader_cache.cc |
| diff --git a/gpu/command_buffer/service/memory_shader_cache.cc b/gpu/command_buffer/service/memory_shader_cache.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1e14d744f0a7efc34e64c86c7e0ef268b5f3f965 |
| --- /dev/null |
| +++ b/gpu/command_buffer/service/memory_shader_cache.cc |
| @@ -0,0 +1,79 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "gpu/command_buffer/service/memory_shader_cache.h" |
| +#include "base/bind.h" |
| +#include "base/file_path.h" |
| +#include "net/disk_cache/disk_cache.h" |
| +#include "ui/gl/gl_bindings.h" |
| + |
| +using disk_cache::Backend; |
| + |
| +namespace gpu { |
| + |
| +//void thing(int a) { |
| +// fprintf(stderr, "got %i from cache callback\n", a); |
| +//} |
| + |
| +MemoryShaderCache::MemoryShaderCache() { |
| +// Backend* backend; |
| +// const FilePath path("shaders"); |
| +// disk_cache::CreateCacheBackend(net::MEMORY_CACHE, path, |
| +// 16 * 1024 * 1024, false, NULL, NULL, &backend, base::Bind(&thing)); |
| +// cache_backend_ = scoped_ptr<Backend>(backend); |
| +} |
| + |
| +MemoryShaderCache::~MemoryShaderCache() { } |
| + |
| +bool MemoryShaderCache::isShaderCacheEnabled() { |
| +#if defined(OS_MACOSX) |
|
greggman
2012/06/15 08:10:24
You need to call glGetString and check for GL_ARB_
dmurph
2012/06/15 16:40:23
Yeah, I ended up not using this method, I'll put t
|
| + return false; |
| +#else |
| + return true; |
| +#endif |
| +} |
| + |
| +CompiledShaderStatus MemoryShaderCache::getShaderCompilationStatus( |
| + const char* shader_src) { |
|
greggman
2012/06/15 08:10:24
would it be better if all of these functions took
dmurph
2012/06/15 16:40:23
Yeah, good idea :)
|
| + CachedShaderKey key(shader_src, "", "", 0, 0); |
| + return shader_status_[key]; |
|
greggman
2012/06/15 08:10:24
If you are just trying to find a key you should ca
dmurph
2012/06/15 16:40:23
It wasn't, thanks for catching this, I'm not super
|
| +} |
| + |
| +void MemoryShaderCache::setShaderCompilationStatus(const char* shader_src, |
| + CompiledShaderStatus status) { |
| + CachedShaderKey key(shader_src, "", "", 0, 0); |
| + shader_status_[key] = status; |
| +} |
| + |
| +LinkedProgramStatus MemoryShaderCache::getLinkedProgramStatus( |
| + const char* untranslated_a, const char* untranslated_b) { |
| + CachedProgramKey key(untranslated_a, untranslated_b, "", "", 0, 0); |
| + return link_status_[key]; |
| +} |
| + |
| +void MemoryShaderCache::setLinkedProgramStatus(const char* untranslated_a, |
| + const char* untranslated_b, LinkedProgramStatus status) { |
| + CachedProgramKey key(untranslated_a, untranslated_b, "", "", 0, 0); |
| + link_status_[key] = status; |
| +} |
| + |
| +void MemoryShaderCache::getLinkedProgram(const char* untranslated_a, |
| + const char* untranslated_b, GLsizei* length, GLenum* binaryFormat, |
| + const GLvoid** binary) { |
| + CachedProgramKey key(untranslated_a, untranslated_b, "", "", 0, 0); |
| + StoreValue value = store_[key]; |
| + *length = value.length; |
| + *binaryFormat = value.format; |
| + *binary = value.data; |
| +} |
| + |
| +void MemoryShaderCache::setLinkedProgram(const char* untranslated_a, |
| + const char* untranslated_b, GLsizei length, GLenum binaryFormat, |
| + GLvoid* binary) { |
| + CachedProgramKey key(untranslated_a, untranslated_b, "", "", 0, 0); |
| + StoreValue value(length, binaryFormat, binary); |
| + store_[key] = value; |
| +} |
| + |
| +} // namespace gpu |