| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/gpu/dxva_picture_buffer_win.h" | 5 #include "media/gpu/dxva_picture_buffer_win.h" |
| 6 | 6 |
| 7 #include "media/gpu/dxva_video_decode_accelerator_win.h" | 7 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
| 8 #include "third_party/angle/include/EGL/egl.h" | 8 #include "third_party/angle/include/EGL/egl.h" |
| 9 #include "third_party/angle/include/EGL/eglext.h" | 9 #include "third_party/angle/include/EGL/eglext.h" |
| 10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 bool PbufferPictureBuffer::Initialize(const DXVAVideoDecodeAccelerator& decoder, | 182 bool PbufferPictureBuffer::Initialize(const DXVAVideoDecodeAccelerator& decoder, |
| 183 EGLConfig egl_config) { | 183 EGLConfig egl_config) { |
| 184 RETURN_ON_FAILURE(!picture_buffer_.service_texture_ids().empty(), | 184 RETURN_ON_FAILURE(!picture_buffer_.service_texture_ids().empty(), |
| 185 "No service texture ids provided", false); | 185 "No service texture ids provided", false); |
| 186 | 186 |
| 187 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); | 187 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
| 188 EGLint use_rgb = 1; | 188 EGLint use_rgb = 1; |
| 189 eglGetConfigAttrib(egl_display, egl_config, EGL_BIND_TO_TEXTURE_RGB, | 189 eglGetConfigAttrib(egl_display, egl_config, EGL_BIND_TO_TEXTURE_RGB, |
| 190 &use_rgb); | 190 &use_rgb); |
| 191 | 191 |
| 192 if (!InitializeTexture(decoder, !!use_rgb)) | 192 EGLint red_bits = 8; |
| 193 eglGetConfigAttrib(egl_display, egl_config, EGL_RED_SIZE, &red_bits); |
| 194 |
| 195 if (!InitializeTexture(decoder, !!use_rgb, red_bits == 16)) |
| 193 return false; | 196 return false; |
| 194 | 197 |
| 195 EGLint attrib_list[] = {EGL_WIDTH, | 198 EGLint attrib_list[] = {EGL_WIDTH, |
| 196 size().width(), | 199 size().width(), |
| 197 EGL_HEIGHT, | 200 EGL_HEIGHT, |
| 198 size().height(), | 201 size().height(), |
| 199 EGL_TEXTURE_FORMAT, | 202 EGL_TEXTURE_FORMAT, |
| 200 use_rgb ? EGL_TEXTURE_RGB : EGL_TEXTURE_RGBA, | 203 use_rgb ? EGL_TEXTURE_RGB : EGL_TEXTURE_RGBA, |
| 201 EGL_TEXTURE_TARGET, | 204 EGL_TEXTURE_TARGET, |
| 202 EGL_TEXTURE_2D, | 205 EGL_TEXTURE_2D, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 216 "Failed to query ANGLE keyed mutex", false); | 219 "Failed to query ANGLE keyed mutex", false); |
| 217 egl_keyed_mutex_ = base::win::ScopedComPtr<IDXGIKeyedMutex>( | 220 egl_keyed_mutex_ = base::win::ScopedComPtr<IDXGIKeyedMutex>( |
| 218 static_cast<IDXGIKeyedMutex*>(keyed_mutex)); | 221 static_cast<IDXGIKeyedMutex*>(keyed_mutex)); |
| 219 } | 222 } |
| 220 use_rgb_ = !!use_rgb; | 223 use_rgb_ = !!use_rgb; |
| 221 return true; | 224 return true; |
| 222 } | 225 } |
| 223 | 226 |
| 224 bool PbufferPictureBuffer::InitializeTexture( | 227 bool PbufferPictureBuffer::InitializeTexture( |
| 225 const DXVAVideoDecodeAccelerator& decoder, | 228 const DXVAVideoDecodeAccelerator& decoder, |
| 226 bool use_rgb) { | 229 bool use_rgb, |
| 230 bool use_fp16) { |
| 227 DCHECK(!texture_share_handle_); | 231 DCHECK(!texture_share_handle_); |
| 228 if (decoder.d3d11_device_) { | 232 if (decoder.d3d11_device_) { |
| 229 D3D11_TEXTURE2D_DESC desc; | 233 D3D11_TEXTURE2D_DESC desc; |
| 230 desc.Width = picture_buffer_.size().width(); | 234 desc.Width = picture_buffer_.size().width(); |
| 231 desc.Height = picture_buffer_.size().height(); | 235 desc.Height = picture_buffer_.size().height(); |
| 232 desc.MipLevels = 1; | 236 desc.MipLevels = 1; |
| 233 desc.ArraySize = 1; | 237 desc.ArraySize = 1; |
| 234 desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; | 238 if (use_fp16) { |
| 239 desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; |
| 240 } else { |
| 241 desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; |
| 242 } |
| 235 desc.SampleDesc.Count = 1; | 243 desc.SampleDesc.Count = 1; |
| 236 desc.SampleDesc.Quality = 0; | 244 desc.SampleDesc.Quality = 0; |
| 237 desc.Usage = D3D11_USAGE_DEFAULT; | 245 desc.Usage = D3D11_USAGE_DEFAULT; |
| 238 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; | 246 desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; |
| 239 desc.CPUAccessFlags = 0; | 247 desc.CPUAccessFlags = 0; |
| 240 desc.MiscFlags = decoder.use_keyed_mutex_ | 248 desc.MiscFlags = decoder.use_keyed_mutex_ |
| 241 ? D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | 249 ? D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX |
| 242 : D3D11_RESOURCE_MISC_SHARED; | 250 : D3D11_RESOURCE_MISC_SHARED; |
| 243 | 251 |
| 244 HRESULT hr = decoder.d3d11_device_->CreateTexture2D( | 252 HRESULT hr = decoder.d3d11_device_->CreateTexture2D( |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 state_ = UNUSED; | 668 state_ = UNUSED; |
| 661 | 669 |
| 662 if (stream_) { | 670 if (stream_) { |
| 663 EGLBoolean result = eglStreamConsumerReleaseKHR(egl_display, stream_); | 671 EGLBoolean result = eglStreamConsumerReleaseKHR(egl_display, stream_); |
| 664 RETURN_ON_FAILURE(result, "Could not release stream", false); | 672 RETURN_ON_FAILURE(result, "Could not release stream", false); |
| 665 } | 673 } |
| 666 return true; | 674 return true; |
| 667 } | 675 } |
| 668 | 676 |
| 669 } // namespace media | 677 } // namespace media |
| OLD | NEW |