1 // 2 // Copyright 2015 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // StateManager11.h: Defines a class for caching D3D11 state 8 9 #ifndef LIBANGLE_RENDERER_D3D11_STATEMANAGER11_H_ 10 #define LIBANGLE_RENDERER_D3D11_STATEMANAGER11_H_ 11 12 #include <array> 13 14 #include "libANGLE/State.h" 15 #include "libANGLE/angletypes.h" 16 #include "libANGLE/renderer/d3d/IndexDataManager.h" 17 #include "libANGLE/renderer/d3d/RendererD3D.h" 18 #include "libANGLE/renderer/d3d/d3d11/InputLayoutCache.h" 19 #include "libANGLE/renderer/d3d/d3d11/Query11.h" 20 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" 21 22 namespace rx 23 { 24 class Buffer11; 25 class DisplayD3D; 26 class Framebuffer11; 27 struct RenderTargetDesc; 28 struct Renderer11DeviceCaps; 29 class VertexArray11; 30 31 class ShaderConstants11 : angle::NonCopyable 32 { 33 public: 34 ShaderConstants11(); 35 ~ShaderConstants11(); 36 37 void init(const gl::Caps &caps); 38 size_t getRequiredBufferSize(gl::ShaderType shaderType) const; 39 void markDirty(); 40 41 void setComputeWorkGroups(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ); 42 void setMultiviewWriteToViewportIndex(GLfloat index); 43 void onViewportChange(const gl::Rectangle &glViewport, 44 const D3D11_VIEWPORT &dxViewport, 45 bool is9_3, 46 bool presentPathFast); 47 bool onFirstVertexChange(GLint firstVertex); 48 void onImageLayerChange(gl::ShaderType shaderType, unsigned int imageIndex, int layer); 49 void onSamplerChange(gl::ShaderType shaderType, 50 unsigned int samplerIndex, 51 const gl::Texture &texture, 52 const gl::SamplerState &samplerState); 53 void onImageChange(gl::ShaderType shaderType, 54 unsigned int imageIndex, 55 const gl::ImageUnit &imageUnit); 56 57 angle::Result updateBuffer(const gl::Context *context, 58 Renderer11 *renderer, 59 gl::ShaderType shaderType, 60 const ProgramD3D &programD3D, 61 const d3d11::Buffer &driverConstantBuffer); 62 63 private: 64 struct Vertex 65 { VertexVertex66 Vertex() 67 : depthRange{.0f}, 68 viewAdjust{.0f}, 69 viewCoords{.0f}, 70 viewScale{.0f}, 71 multiviewWriteToViewportIndex{.0f}, 72 firstVertex{0} 73 {} 74 75 float depthRange[4]; 76 float viewAdjust[4]; 77 float viewCoords[4]; 78 float viewScale[2]; 79 // multiviewWriteToViewportIndex is used to select either the side-by-side or layered 80 // code-path in the GS. It's value, if set, is either 0.0f or 1.0f. The value is updated 81 // whenever a multi-view draw framebuffer is made active. 82 float multiviewWriteToViewportIndex; 83 84 uint32_t firstVertex; 85 }; 86 87 struct Pixel 88 { PixelPixel89 Pixel() 90 : depthRange{.0f}, 91 viewCoords{.0f}, 92 depthFront{.0f}, 93 viewScale{.0f}, 94 multiviewWriteToViewportIndex(0), 95 padding(0) 96 {} 97 98 float depthRange[4]; 99 float viewCoords[4]; 100 float depthFront[4]; 101 float viewScale[2]; 102 // multiviewWriteToViewportIndex is used to select either the side-by-side or layered 103 // code-path in the GS. It's value, if set, is either 0.0f or 1.0f. The value is updated 104 // whenever a multi-view draw framebuffer is made active. 105 float multiviewWriteToViewportIndex; 106 107 // Added here to manually pad the struct. 108 float padding; 109 }; 110 111 struct Compute 112 { ComputeCompute113 Compute() : numWorkGroups{0u}, padding(0u) {} 114 unsigned int numWorkGroups[3]; 115 unsigned int padding; // This just pads the struct to 16 bytes 116 }; 117 118 struct SamplerMetadata 119 { SamplerMetadataSamplerMetadata120 SamplerMetadata() 121 : baseLevel(0), internalFormatBits(0), wrapModes(0), padding(0), intBorderColor{0} 122 {} 123 124 int baseLevel; 125 int internalFormatBits; 126 int wrapModes; 127 int padding; // This just pads the struct to 32 bytes 128 int intBorderColor[4]; 129 }; 130 131 static_assert(sizeof(SamplerMetadata) == 32u, 132 "Sampler metadata struct must be two 4-vec --> 32 bytes."); 133 134 struct ImageMetadata 135 { ImageMetadataImageMetadata136 ImageMetadata() : layer(0), level(0), padding{0} {} 137 138 int layer; 139 unsigned int level; 140 int padding[2]; // This just pads the struct to 16 bytes 141 }; 142 static_assert(sizeof(ImageMetadata) == 16u, 143 "Image metadata struct must be one 4-vec --> 16 bytes."); 144 145 static size_t GetShaderConstantsStructSize(gl::ShaderType shaderType); 146 147 // Return true if dirty. 148 bool updateSamplerMetadata(SamplerMetadata *data, 149 const gl::Texture &texture, 150 const gl::SamplerState &samplerState); 151 152 // Return true if dirty. 153 bool updateImageMetadata(ImageMetadata *data, const gl::ImageUnit &imageUnit); 154 155 Vertex mVertex; 156 Pixel mPixel; 157 Compute mCompute; 158 gl::ShaderBitSet mShaderConstantsDirty; 159 160 gl::ShaderMap<std::vector<SamplerMetadata>> mShaderSamplerMetadata; 161 gl::ShaderMap<int> mNumActiveShaderSamplers; 162 gl::ShaderMap<std::vector<ImageMetadata>> mShaderReadonlyImageMetadata; 163 gl::ShaderMap<int> mNumActiveShaderReadonlyImages; 164 gl::ShaderMap<std::vector<ImageMetadata>> mShaderImageMetadata; 165 gl::ShaderMap<int> mNumActiveShaderImages; 166 }; 167 168 class StateManager11 final : angle::NonCopyable 169 { 170 public: 171 StateManager11(Renderer11 *renderer); 172 ~StateManager11(); 173 174 void deinitialize(); 175 176 void syncState(const gl::Context *context, const gl::State::DirtyBits &dirtyBits); 177 178 angle::Result updateStateForCompute(const gl::Context *context, 179 GLuint numGroupsX, 180 GLuint numGroupsY, 181 GLuint numGroupsZ); 182 183 void updateStencilSizeIfChanged(bool depthStencilInitialized, unsigned int stencilSize); 184 185 // These invalidations methods are called externally. 186 187 // Called from TextureStorage11. 188 void invalidateBoundViews(); 189 190 // Called from VertexArray11::updateVertexAttribStorage. 191 void invalidateCurrentValueAttrib(size_t attribIndex); 192 193 // Checks are done on a framebuffer state change to trigger other state changes. 194 // The Context is allowed to be nullptr for these methods, when called in EGL init code. 195 void invalidateRenderTarget(); 196 197 // Called by instanced point sprite emulation. 198 void invalidateVertexBuffer(); 199 200 // Called by Framebuffer11::syncState for the default sized viewport. 201 void invalidateViewport(const gl::Context *context); 202 203 // Called by TextureStorage11::markLevelDirty. 204 void invalidateSwizzles(); 205 206 // Called by the Framebuffer11 and VertexArray11. 207 void invalidateShaders(); 208 209 // Called by the Program on Uniform Buffer change. Also called internally. 210 void invalidateProgramUniformBuffers(); 211 212 // Called by TransformFeedback11. 213 void invalidateTransformFeedback(); 214 215 // Called by VertexArray11. 216 void invalidateInputLayout(); 217 218 // Called by VertexArray11 element array buffer sync. 219 void invalidateIndexBuffer(); 220 221 // Called by TextureStorage11. Also called internally. 222 void invalidateTexturesAndSamplers(); 223 224 void setRenderTarget(ID3D11RenderTargetView *rtv, ID3D11DepthStencilView *dsv); 225 void setRenderTargets(ID3D11RenderTargetView **rtvs, UINT numRtvs, ID3D11DepthStencilView *dsv); 226 227 void onBeginQuery(Query11 *query); 228 void onDeleteQueryObject(Query11 *query); 229 angle::Result onMakeCurrent(const gl::Context *context); 230 231 void setInputLayout(const d3d11::InputLayout *inputLayout); 232 233 void setSingleVertexBuffer(const d3d11::Buffer *buffer, UINT stride, UINT offset); 234 235 angle::Result updateState(const gl::Context *context, 236 gl::PrimitiveMode mode, 237 GLint firstVertex, 238 GLsizei vertexOrIndexCount, 239 gl::DrawElementsType indexTypeOrInvalid, 240 const void *indices, 241 GLsizei instanceCount, 242 GLint baseVertex, 243 GLuint baseInstance, 244 bool promoteDynamic); 245 246 void setShaderResourceShared(gl::ShaderType shaderType, 247 UINT resourceSlot, 248 const d3d11::SharedSRV *srv); 249 void setShaderResource(gl::ShaderType shaderType, 250 UINT resourceSlot, 251 const d3d11::ShaderResourceView *srv); 252 void setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology); 253 254 void setDrawShaders(const d3d11::VertexShader *vertexShader, 255 const d3d11::GeometryShader *geometryShader, 256 const d3d11::PixelShader *pixelShader); 257 void setVertexShader(const d3d11::VertexShader *shader); 258 void setGeometryShader(const d3d11::GeometryShader *shader); 259 void setPixelShader(const d3d11::PixelShader *shader); 260 void setComputeShader(const d3d11::ComputeShader *shader); 261 void setVertexConstantBuffer(unsigned int slot, const d3d11::Buffer *buffer); 262 void setPixelConstantBuffer(unsigned int slot, const d3d11::Buffer *buffer); 263 void setDepthStencilState(const d3d11::DepthStencilState *depthStencilState, UINT stencilRef); 264 void setSimpleBlendState(const d3d11::BlendState *blendState); 265 void setRasterizerState(const d3d11::RasterizerState *rasterizerState); 266 void setSimpleViewport(const gl::Extents &viewportExtents); 267 void setSimpleViewport(int width, int height); 268 void setSimplePixelTextureAndSampler(const d3d11::SharedSRV &srv, 269 const d3d11::SamplerState &samplerState); 270 void setSimpleScissorRect(const gl::Rectangle &glRect); 271 void setScissorRectD3D(const D3D11_RECT &d3dRect); 272 273 void setIndexBuffer(ID3D11Buffer *buffer, DXGI_FORMAT indexFormat, unsigned int offset); 274 275 angle::Result updateVertexOffsetsForPointSpritesEmulation(const gl::Context *context, 276 GLint startVertex, 277 GLsizei emulatedInstanceId); 278 279 // TODO(jmadill): Should be private. 280 angle::Result applyComputeUniforms(const gl::Context *context, ProgramD3D *programD3D); 281 282 // Only used in testing. getInputLayoutCache()283 InputLayoutCache *getInputLayoutCache() { return &mInputLayoutCache; } 284 getCullEverything()285 bool getCullEverything() const { return mCullEverything; } getVertexDataManager()286 VertexDataManager *getVertexDataManager() { return &mVertexDataManager; } 287 getProgramD3D()288 ProgramD3D *getProgramD3D() const { return mProgramD3D; } 289 290 private: 291 angle::Result ensureInitialized(const gl::Context *context); 292 293 template <typename SRVType> 294 void setShaderResourceInternal(gl::ShaderType shaderType, 295 UINT resourceSlot, 296 const SRVType *srv); 297 template <typename UAVType> 298 void setUnorderedAccessViewInternal(gl::ShaderType shaderType, 299 UINT resourceSlot, 300 const UAVType *uav); 301 302 void unsetConflictingView(gl::PipelineType pipeline, ID3D11View *view, bool isRenderTarget); 303 void unsetConflictingSRVs(gl::PipelineType pipeline, 304 gl::ShaderType shaderType, 305 uintptr_t resource, 306 const gl::ImageIndex *index, 307 bool isRenderTarget); 308 void unsetConflictingUAVs(gl::PipelineType pipeline, 309 gl::ShaderType shaderType, 310 uintptr_t resource, 311 const gl::ImageIndex *index); 312 void unsetConflictingRTVs(uintptr_t resource); 313 314 void unsetConflictingAttachmentResources(const gl::FramebufferAttachment &attachment, 315 ID3D11Resource *resource); 316 317 angle::Result syncBlendState(const gl::Context *context, 318 const gl::BlendStateExt &blendStateExt, 319 const gl::ColorF &blendColor, 320 unsigned int sampleMask, 321 bool sampleAlphaToCoverage, 322 bool emulateConstantAlpha); 323 324 angle::Result syncDepthStencilState(const gl::Context *context); 325 326 angle::Result syncRasterizerState(const gl::Context *context, gl::PrimitiveMode mode); 327 328 void syncScissorRectangle(const gl::Context *context); 329 330 void syncViewport(const gl::Context *context); 331 332 void checkPresentPath(const gl::Context *context); 333 334 angle::Result syncFramebuffer(const gl::Context *context); 335 angle::Result syncProgram(const gl::Context *context, gl::PrimitiveMode drawMode); 336 angle::Result syncProgramForCompute(const gl::Context *context); 337 338 angle::Result syncTextures(const gl::Context *context); 339 angle::Result applyTexturesForSRVs(const gl::Context *context, gl::ShaderType shaderType); 340 angle::Result applyTexturesForUAVs(const gl::Context *context, gl::ShaderType shaderType); 341 angle::Result syncTexturesForCompute(const gl::Context *context); 342 343 angle::Result setSamplerState(const gl::Context *context, 344 gl::ShaderType type, 345 int index, 346 gl::Texture *texture, 347 const gl::SamplerState &sampler); 348 angle::Result setTextureForSampler(const gl::Context *context, 349 gl::ShaderType type, 350 int index, 351 gl::Texture *texture, 352 const gl::SamplerState &sampler); 353 angle::Result setImageState(const gl::Context *context, 354 gl::ShaderType type, 355 int index, 356 const gl::ImageUnit &imageUnit); 357 angle::Result setTextureForImage(const gl::Context *context, 358 gl::ShaderType type, 359 int index, 360 bool readonly, 361 const gl::ImageUnit &imageUnit); 362 363 void handleMultiviewDrawFramebufferChange(const gl::Context *context); 364 365 angle::Result syncCurrentValueAttribs( 366 const gl::Context *context, 367 const std::vector<gl::VertexAttribCurrentValueData> ¤tValues); 368 369 angle::Result generateSwizzle(const gl::Context *context, gl::Texture *texture); 370 angle::Result generateSwizzlesForShader(const gl::Context *context, gl::ShaderType type); 371 angle::Result generateSwizzles(const gl::Context *context); 372 373 angle::Result applyDriverUniforms(const gl::Context *context); 374 angle::Result applyDriverUniformsForShader(const gl::Context *context, 375 gl::ShaderType shaderType); 376 angle::Result applyUniforms(const gl::Context *context); 377 angle::Result applyUniformsForShader(const gl::Context *context, gl::ShaderType shaderType); 378 379 angle::Result syncShaderStorageBuffersForShader(const gl::Context *context, 380 gl::ShaderType shaderType); 381 382 angle::Result syncUniformBuffers(const gl::Context *context); 383 angle::Result syncUniformBuffersForShader(const gl::Context *context, 384 gl::ShaderType shaderType); 385 angle::Result syncAtomicCounterBuffers(const gl::Context *context); 386 angle::Result syncAtomicCounterBuffersForShader(const gl::Context *context, 387 gl::ShaderType shaderType); 388 angle::Result syncShaderStorageBuffers(const gl::Context *context); 389 angle::Result syncTransformFeedbackBuffers(const gl::Context *context); 390 391 // These are currently only called internally. 392 void invalidateDriverUniforms(); 393 void invalidateProgramUniforms(); 394 void invalidateConstantBuffer(unsigned int slot); 395 void invalidateProgramAtomicCounterBuffers(); 396 void invalidateProgramShaderStorageBuffers(); 397 398 // Called by the Framebuffer11 directly. 399 void processFramebufferInvalidation(const gl::Context *context); 400 401 bool syncIndexBuffer(ID3D11Buffer *buffer, DXGI_FORMAT indexFormat, unsigned int offset); 402 angle::Result syncVertexBuffersAndInputLayout(const gl::Context *context, 403 gl::PrimitiveMode mode, 404 GLint firstVertex, 405 GLsizei vertexOrIndexCount, 406 gl::DrawElementsType indexTypeOrInvalid, 407 GLsizei instanceCount); 408 409 bool setInputLayoutInternal(const d3d11::InputLayout *inputLayout); 410 411 angle::Result applyVertexBuffers(const gl::Context *context, 412 gl::PrimitiveMode mode, 413 gl::DrawElementsType indexTypeOrInvalid, 414 GLint firstVertex); 415 // TODO(jmadill): Migrate to d3d11::Buffer. 416 bool queueVertexBufferChange(size_t bufferIndex, 417 ID3D11Buffer *buffer, 418 UINT stride, 419 UINT offset); 420 void applyVertexBufferChanges(); 421 bool setPrimitiveTopologyInternal(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology); 422 void syncPrimitiveTopology(const gl::State &glState, gl::PrimitiveMode currentDrawMode); 423 424 // Not handled by an internal dirty bit because it isn't synced on drawArrays calls. 425 angle::Result applyIndexBuffer(const gl::Context *context, 426 GLsizei indexCount, 427 gl::DrawElementsType indexType, 428 const void *indices); 429 430 enum DirtyBitType 431 { 432 DIRTY_BIT_RENDER_TARGET, 433 DIRTY_BIT_VIEWPORT_STATE, 434 DIRTY_BIT_SCISSOR_STATE, 435 DIRTY_BIT_RASTERIZER_STATE, 436 DIRTY_BIT_BLEND_STATE, 437 DIRTY_BIT_DEPTH_STENCIL_STATE, 438 // DIRTY_BIT_SHADERS and DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE should be dealt before 439 // DIRTY_BIT_PROGRAM_UNIFORM_BUFFERS for update image layers. 440 DIRTY_BIT_SHADERS, 441 // DIRTY_BIT_GRAPHICS_SRVUAV_STATE and DIRTY_BIT_COMPUTE_SRVUAV_STATE should be lower 442 // bits than DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE. 443 DIRTY_BIT_GRAPHICS_SRVUAV_STATE, 444 DIRTY_BIT_COMPUTE_SRVUAV_STATE, 445 DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE, 446 DIRTY_BIT_PROGRAM_UNIFORMS, 447 DIRTY_BIT_DRIVER_UNIFORMS, 448 DIRTY_BIT_PROGRAM_UNIFORM_BUFFERS, 449 DIRTY_BIT_PROGRAM_ATOMIC_COUNTER_BUFFERS, 450 DIRTY_BIT_PROGRAM_SHADER_STORAGE_BUFFERS, 451 DIRTY_BIT_CURRENT_VALUE_ATTRIBS, 452 DIRTY_BIT_TRANSFORM_FEEDBACK, 453 DIRTY_BIT_VERTEX_BUFFERS_AND_INPUT_LAYOUT, 454 DIRTY_BIT_PRIMITIVE_TOPOLOGY, 455 DIRTY_BIT_INVALID, 456 DIRTY_BIT_MAX = DIRTY_BIT_INVALID, 457 }; 458 459 using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>; 460 461 Renderer11 *mRenderer; 462 463 // Internal dirty bits. 464 DirtyBits mInternalDirtyBits; 465 DirtyBits mGraphicsDirtyBitsMask; 466 DirtyBits mComputeDirtyBitsMask; 467 468 bool mCurSampleAlphaToCoverage; 469 470 // Blend State 471 gl::BlendStateExt mCurBlendStateExt; 472 gl::ColorF mCurBlendColor; 473 unsigned int mCurSampleMask; 474 475 // Currently applied depth stencil state 476 gl::DepthStencilState mCurDepthStencilState; 477 int mCurStencilRef; 478 int mCurStencilBackRef; 479 unsigned int mCurStencilSize; 480 Optional<bool> mCurDisableDepth; 481 Optional<bool> mCurDisableStencil; 482 483 // Currently applied rasterizer state 484 gl::RasterizerState mCurRasterState; 485 486 // Currently applied scissor rectangle state 487 bool mCurScissorEnabled; 488 gl::Rectangle mCurScissorRect; 489 490 // Currently applied viewport state 491 gl::Rectangle mCurViewport; 492 float mCurNear; 493 float mCurFar; 494 495 // Currently applied offset to viewport and scissor 496 gl::Offset mCurViewportOffset; 497 gl::Offset mCurScissorOffset; 498 499 // Things needed in viewport state 500 ShaderConstants11 mShaderConstants; 501 502 // Render target variables 503 gl::Extents mViewportBounds; 504 bool mRenderTargetIsDirty; 505 506 // EGL_ANGLE_experimental_present_path variables 507 bool mCurPresentPathFastEnabled; 508 int mCurPresentPathFastColorBufferHeight; 509 510 // Queries that are currently active in this state 511 std::set<Query11 *> mCurrentQueries; 512 513 // Currently applied textures 514 template <typename DescType> 515 struct ViewRecord 516 { 517 uintptr_t view; 518 uintptr_t resource; 519 DescType desc; 520 }; 521 522 // A cache of current Views that also tracks the highest 'used' (non-NULL) View. 523 // We might want to investigate a more robust approach that is also fast when there's 524 // a large gap between used Views (e.g. if View 0 and 7 are non-NULL, this approach will 525 // waste time on Views 1-6.) 526 template <typename ViewType, typename DescType> 527 class ViewCache : angle::NonCopyable 528 { 529 public: 530 ViewCache(); 531 ~ViewCache(); 532 initialize(size_t size)533 void initialize(size_t size) { mCurrentViews.resize(size); } 534 size()535 size_t size() const { return mCurrentViews.size(); } highestUsed()536 size_t highestUsed() const { return mHighestUsedView; } 537 538 const ViewRecord<DescType> &operator[](size_t index) const { return mCurrentViews[index]; } 539 void clear(); 540 void update(size_t resourceIndex, ViewType *view); 541 542 private: 543 std::vector<ViewRecord<DescType>> mCurrentViews; 544 size_t mHighestUsedView; 545 }; 546 547 using SRVCache = ViewCache<ID3D11ShaderResourceView, D3D11_SHADER_RESOURCE_VIEW_DESC>; 548 using UAVCache = ViewCache<ID3D11UnorderedAccessView, D3D11_UNORDERED_ACCESS_VIEW_DESC>; 549 using RTVCache = ViewCache<ID3D11RenderTargetView, D3D11_RENDER_TARGET_VIEW_DESC>; 550 gl::ShaderMap<SRVCache> mCurShaderSRVs; 551 UAVCache mCurComputeUAVs; 552 RTVCache mCurRTVs; 553 554 SRVCache *getSRVCache(gl::ShaderType shaderType); 555 556 // A block of NULL pointers, cached so we don't re-allocate every draw call 557 std::vector<ID3D11ShaderResourceView *> mNullSRVs; 558 std::vector<ID3D11UnorderedAccessView *> mNullUAVs; 559 560 // Current translations of "Current-Value" data - owned by Context, not VertexArray. 561 gl::AttributesMask mDirtyCurrentValueAttribs; 562 std::vector<TranslatedAttribute> mCurrentValueAttribs; 563 564 // Current applied input layout. 565 ResourceSerial mCurrentInputLayout; 566 567 // Current applied vertex states. 568 // TODO(jmadill): Figure out how to use ResourceSerial here. 569 gl::AttribArray<ID3D11Buffer *> mCurrentVertexBuffers; 570 gl::AttribArray<UINT> mCurrentVertexStrides; 571 gl::AttribArray<UINT> mCurrentVertexOffsets; 572 gl::RangeUI mDirtyVertexBufferRange; 573 574 // Currently applied primitive topology 575 D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology; 576 gl::PrimitiveMode mLastAppliedDrawMode; 577 bool mCullEverything; 578 579 // Currently applied shaders 580 gl::ShaderMap<ResourceSerial> mAppliedShaders; 581 582 // Currently applied sampler states 583 gl::ShaderMap<std::vector<bool>> mForceSetShaderSamplerStates; 584 gl::ShaderMap<std::vector<gl::SamplerState>> mCurShaderSamplerStates; 585 586 // Special dirty bit for swizzles. Since they use internal shaders, must be done in a pre-pass. 587 bool mDirtySwizzles; 588 589 // Currently applied index buffer 590 ID3D11Buffer *mAppliedIB; 591 DXGI_FORMAT mAppliedIBFormat; 592 unsigned int mAppliedIBOffset; 593 bool mIndexBufferIsDirty; 594 595 // Vertex, index and input layouts 596 VertexDataManager mVertexDataManager; 597 IndexDataManager mIndexDataManager; 598 InputLayoutCache mInputLayoutCache; 599 std::vector<const TranslatedAttribute *> mCurrentAttributes; 600 Optional<GLint> mLastFirstVertex; 601 602 // ANGLE_multiview. 603 bool mIsMultiviewEnabled; 604 605 bool mIndependentBlendStates; 606 607 // Driver Constants. 608 gl::ShaderMap<d3d11::Buffer> mShaderDriverConstantBuffers; 609 610 ResourceSerial mCurrentComputeConstantBuffer; 611 ResourceSerial mCurrentGeometryConstantBuffer; 612 613 d3d11::Buffer mPointSpriteVertexBuffer; 614 d3d11::Buffer mPointSpriteIndexBuffer; 615 616 template <typename T> 617 using VertexConstantBufferArray = 618 std::array<T, gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS>; 619 620 VertexConstantBufferArray<ResourceSerial> mCurrentConstantBufferVS; 621 VertexConstantBufferArray<GLintptr> mCurrentConstantBufferVSOffset; 622 VertexConstantBufferArray<GLsizeiptr> mCurrentConstantBufferVSSize; 623 624 template <typename T> 625 using FragmentConstantBufferArray = 626 std::array<T, gl::IMPLEMENTATION_MAX_FRAGMENT_SHADER_UNIFORM_BUFFERS>; 627 628 FragmentConstantBufferArray<ResourceSerial> mCurrentConstantBufferPS; 629 FragmentConstantBufferArray<GLintptr> mCurrentConstantBufferPSOffset; 630 FragmentConstantBufferArray<GLsizeiptr> mCurrentConstantBufferPSSize; 631 632 template <typename T> 633 using ComputeConstantBufferArray = 634 std::array<T, gl::IMPLEMENTATION_MAX_COMPUTE_SHADER_UNIFORM_BUFFERS>; 635 636 ComputeConstantBufferArray<ResourceSerial> mCurrentConstantBufferCS; 637 ComputeConstantBufferArray<GLintptr> mCurrentConstantBufferCSOffset; 638 ComputeConstantBufferArray<GLsizeiptr> mCurrentConstantBufferCSSize; 639 640 // Currently applied transform feedback buffers 641 Serial mAppliedTFSerial; 642 643 Serial mEmptySerial; 644 645 // These objects are cached to avoid having to query the impls. 646 ProgramD3D *mProgramD3D; 647 VertexArray11 *mVertexArray11; 648 Framebuffer11 *mFramebuffer11; 649 }; 650 651 } // namespace rx 652 #endif // LIBANGLE_RENDERER_D3D11_STATEMANAGER11_H_ 653